Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping of Eloquent models to tables?

We are able to create Eloquent models for tables. But how Laravel knows to which table to associate a model with? Do we have something similar to hbm.xml(mapping file we use for Hibernate) which says this model means this table.

like image 881
Kannan Ramamoorthy Avatar asked Feb 17 '16 12:02

Kannan Ramamoorthy


1 Answers

The table name is a protected property:

class User extends Eloquent {
    protected $table = 'my_users';
 }

Laravel Docs

like image 126
florin.prisecariu Avatar answered Oct 16 '22 11:10

florin.prisecariu