Reputation: 77
I'm programming a 'module permission management' system that is multi-language capable. I'm using three related tables:
modules, modules_trans, modules_permissions
Is it acceptable (best practice) to use a single model to handle all three related tables in Laravel?
Upvotes: 3
Views: 609
Reputation: 3572
From what I understand, your relationships can be as follows
class Language
{
public function modules()
{
return $this->belongsToMany('App\Module');
}
}
class Permission
{
public function modules()
{
return $this->belongsToMany('App\Module');
}
}
class Module
{
public function languages()
{
return $this->belongsToMany('App\Language');
}
public function permissions()
{
return $this->belongsToMany('App\Permission');
}
}
Your Database should follow the ACID (wiki) as much as possible! So.... No! don't mix up things. Not atleast if your relationships are as specified above.
Therefore, your tables must be as follows...
module
id | name | ....
language_module
id | language_id | module_id
module_permission
id | module_id | permission_id
Upvotes: 2