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