canDo('matrix_level.matrix_level.view') && $user->isAdmin()) { return true; } return $matrix_level->user_id == user_id() && $matrix_level->user_type == user_type(); } /** * Determine if the given user can create a matrix_level. * * @param UserPolicy $user * @param MatrixLevel $matrix_level * * @return bool */ public function create(UserPolicy $user) { return $user->canDo('matrix_level.matrix_level.create'); } /** * Determine if the given user can update the given matrix_level. * * @param UserPolicy $user * @param MatrixLevel $matrix_level * * @return bool */ public function update(UserPolicy $user, MatrixLevel $matrix_level) { if ($user->canDo('matrix_level.matrix_level.edit') && $user->isAdmin()) { return true; } return $matrix_level->user_id == user_id() && $matrix_level->user_type == user_type(); } /** * Determine if the given user can delete the given matrix_level. * * @param UserPolicy $user * @param MatrixLevel $matrix_level * * @return bool */ public function destroy(UserPolicy $user, MatrixLevel $matrix_level) { return $matrix_level->user_id == user_id() && $matrix_level->user_type == user_type(); } /** * Determine if the given user can verify the given matrix_level. * * @param UserPolicy $user * @param MatrixLevel $matrix_level * * @return bool */ public function verify(UserPolicy $user, MatrixLevel $matrix_level) { if ($user->canDo('matrix_level.matrix_level.verify')) { return true; } return false; } /** * Determine if the given user can approve the given matrix_level. * * @param UserPolicy $user * @param MatrixLevel $matrix_level * * @return bool */ public function approve(UserPolicy $user, MatrixLevel $matrix_level) { if ($user->canDo('matrix_level.matrix_level.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; } } }