Laravel Disable Timestamps

Suppose, your database table does not have created_at, updated_at fields and you are trying to create or update a record with the eloquent model. In this situation, you will get an error for those fields.

To solve the issue, just add this line in your model:

public $timestamps = false;

An example:

class Product extends Model
    use HasFactory;

    public $timestamps = false;

You can take a look at the video:

Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.