Disable Timestamps in Laravel

If your DB table doesn’t have timestamp fields (created_at and updated_at), then

$password = Hash::make('password');
$arrayOfValues = array('name'=>'Nikunj Joshi','email'=>'info@nikunjjoshiphpdeveloper.com','password'=>$password);

you will get SQL error. Laravel would try to automatically fill in created_at/updated_at and wouldn’t find them.

To disable that automatic timestamps, in your Model you need to add one property:

class User extends Model
public $timestamps = FALSE;

// ... other model properties and methods

That’s it, quick but hopefully useful tips!

If you have any query or suggestions, feel free to ask me via the comment section below.

Leave a Reply