Working with different table name for a model

If we need to work with a model with different table name which is usually needed for old projects where tbl names could not be changed. Then we can use following snippet

// In model 
protected $table = 'article' // without plural form.. laravel usually uses plural form for their tables such as: articles

Related Posts


Changing timestamp field names

Setting up custom date format

Using fillable or guarded