As we know, Laravel added two field "created_at" and "updated_at" with timestamps. So when new record will be add then created_at and updated_at columns update current timestamps updated and when update then update then updated_at column. This is a default by laravel.
But sometime, we dose not need to add created_at and updated_at column. So we have to stop add update those column, otherwise it returns error. So you can stop it using model $timestamps. Model contain timestamps variable with by default true value. So we have to simply false it. Like as bellow example:
LogActivity.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class LogActivity extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'subject', 'url', 'method', 'ip', 'agent', 'user_id'
];
protected $table = 'log_activities';
public $timestamps = false;
}
I hope you found your solution...
Do you like below Tutorials ?
- How to Open URL in New Tab using Jquery?
- Laravel 7.x and 6.x Routing Tutorial
- Ng Bootstrap Modal in Angular 8 Example
- Bootstrap 4 Datepicker in Angular 9/8 Example
- Disable Registration Route in Laravel
- Bootstrap Timepicker in Angular Example
- Count Number of Pages in PDF - PHP Script
- Digital Signature PHP Script Example