I have to create an application with 5 types of roles.
So I started nesting my controllers
Controllers administrator/establishments.php supervisor/establishments.php
Views
administrator/establishments/index.php supervisors/establishments/index.php
But I noticed that they have almost THE SAME CODE and the count of files will be huge!
I have been thinking in some ways to solve this
Controllers
establishments.php
and then ask:
if (Request::is('admin/*'))
{
Establishments::paginate(20);
}
if (Request::is('supervisor/*'))
{
Establishments::where_country(1)->paginate(20);
}
same for views.
Save role on session info, and create a menu to switch the var from one user to another
$role = Session::get('role');
if ($role == 'admin'))
{
Establishments::paginate(20);
}
if ($role == 'supervisor'))
{
Establishments::where_country(1)->paginate(20);
}
Any other ideas or suggestions?