changing auto incremeneting field names

Like different table names it is also usually needed for old projects where incrementing field names for a table could not be changed. It can be done with following snippets.

// In model
protected $primaryKey = 'article_id' // by default it is set as 'id' in laravel framework

Related Posts


Changing timestamp field names

Setting up custom date format

Using fillable or guarded