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:
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 ?
- Laravel - chmod(storage/oauth-private.key): Operation failed: Operation not permitted
- Laravel 7.x and 6.x datatables example from scratch
- How to compress PNG image using pngquant in PHP?
- Laravel 7.x and 6.x Chart example using Charts Package
- Guzzle http client GET and POST request example in Laravel 5
- Laravel schema default current timestamp value example
- Laravel 7.x and 6.x Get Site URL Examples
- Convert object to array in laravel 7.x and 6.x example