user4332766
user4332766

Reputation:

Laravel naming multiple model class name who are related with each other

i'm just thinking here, i had multiple tables related to the student, things like: history, bulletin, parents, course, and a lot more... when i need create a new student, all this tables need to be filled. i'm using Laravel and the recomended is create a model to each table, my problem is now, naming the model name, what's the best aproach? model with table name or a name related to what the model is?

There are only two hard things in Computer Science: cache invalidation and naming things.

-- Phil Karlton

Upvotes: 0

Views: 622

Answers (1)

l.g.karolos
l.g.karolos

Reputation: 1142

There are many conventions for "Models" - Laravel just doesn't bottleneck you or your project into using any one method as long as the model name is clear and has its own table you are following best practices.

for organizational purposes you can add all the related models under the same folder,this is something for you (and your development team, if you're a part of one) to decide on.

   ├── app
   │   ├── Models <---- folder
   │   │   ├── Students <---- folder
   │   │   │   ├── Student.php    \
   │   │   │   ├── History.php     \ ____ Models
   │   │   │   ├── Bulletin.php    /
   │   │   │   ├── Course.php     /

Upvotes: 1

Related Questions