Disable timestamps(created_at and updated_at) in Laravel 5 Model

July 11, 2017 | Category : Laravel PHP

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:



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...