How should I name the tables and models for user category and article category? I have two tables one users and the other articles. I want to categorize these so that I can for example just call the news articles or use just users that are in the company category. So I need relationships between these models/tables.
I thought about to use a single table and a single model for both article and user but these two don't have much in common plus that could be a problem when I'll bind the relationships between them.
Laravel uses the singular style naming for pivot table, I don't want to break that. So I can't use singular names for these as well. My current choice is:
Article --> main model
articles --> main table
ArticleCategory --> relational model
articles_categories --> relational table
--------------------------------------
User --> main model
users --> main table
UserCategory --> relational model
users_categories --> relational table
So what do you think? Should I use this way or is there a better way to go?
Using a Eloquent Model you can set table name for your particular model.Simple example for User model is as below:-
class User extends Eloquent {
protected $table = 'articles';
}
check this Eloquent you can easily understand. Thanks
best way is:php artisan make:model User -m with this way laravel create model and migration name and file automatically