canDo('employee.dependents.view') && $user->isAdmin()) { return true; } return $dependents->user_id == user_id() && $dependents->user_type == user_type(); } /** * Determine if the given user can create a dependents. * * @param UserPolicy $user * @param Dependents $dependents * * @return bool */ public function create(UserPolicy $user) { return $user->canDo('employee.dependents.create'); } /** * Determine if the given user can update the given dependents. * * @param UserPolicy $user * @param Dependents $dependents * * @return bool */ public function update(UserPolicy $user, Dependents $dependents) { if ($user->canDo('employee.dependents.edit') && $user->isAdmin()) { return true; } return $dependents->user_id == user_id() && $dependents->user_type == user_type(); } /** * Determine if the given user can delete the given dependents. * * @param UserPolicy $user * @param Dependents $dependents * * @return bool */ public function destroy(UserPolicy $user, Dependents $dependents) { return $dependents->user_id == user_id() && $dependents->user_type == user_type(); } /** * Determine if the given user can verify the given dependents. * * @param UserPolicy $user * @param Dependents $dependents * * @return bool */ public function verify(UserPolicy $user, Dependents $dependents) { if ($user->canDo('employee.dependents.verify')) { return true; } return false; } /** * Determine if the given user can approve the given dependents. * * @param UserPolicy $user * @param Dependents $dependents * * @return bool */ public function approve(UserPolicy $user, Dependents $dependents) { if ($user->canDo('employee.dependents.approve')) { return true; } return false; } /** * Determine if the user can perform a given action ve. * * @param [type] $user [description] * @param [type] $ability [description] * * @return [type] [description] */ public function before($user, $ability) { if ($user->isSuperuser()) { return true; } } }