I have this idea to improve my policies. What about adding an edit method in the policy ?
public function edit(User $user, Room $room)
{
return (in_array(0, session('roles')) || in_array(4, session('roles'))) && $room->company_id == session('current_company_id');
}
public function update(User $user, Room $room)
{
return Role::where('collaborator_id', $user->current_collaborator_id)->whereIn('role', [0, 1])->exists() && $room->company_id == session('current_company_id');
}
Check the roles from the session just to display the menus, disable the buttons, ...
But for real update in the database, I retrieve all roles directly from the database.
Is it a good idea to do that ?