canDo('k_b.province.view') && $user->is('admin')) { return true; } if ($user->canDo('blocks.block.view') && $user->is('manager') && $block->user->parent_id == $user->id) { return true; } return $user->id === $province->user_id; } /** * Determine if the given user can create a province. * * @param User $user * @param Province $province * * @return bool */ public function create(User $user) { return $user->canDo('k_b.province.create'); } /** * Determine if the given user can update the given province. * * @param User $user * @param Province $province * * @return bool */ public function update(User $user, Province $province) { if ($user->canDo('k_b.province.update') && $user->is('admin')) { return true; } if ($user->canDo('blocks.block.update') && $user->is('manager') && $block->user->parent_id == $user->id) { return true; } return $user->id === $province->user_id; } /** * Determine if the given user can delete the given province. * * @param User $user * @param Province $province * * @return bool */ public function destroy(User $user, Province $province) { if ($user->canDo('k_b.province.delete') && $user->is('admin')) { return true; } if ($user->canDo('blocks.block.delete') && $user->is('manager') && $block->user->parent_id == $user->id) { return true; } return $user->id === $province->user_id; } /** * Determine if the given user can verify the given province. * * @param User $user * @param Province $province * * @return bool */ public function verify(User $user, Province $province) { if ($user->canDo('k_b.province.verify') && $user->is('admin')) { return true; } if ($user->canDo('k_b.province.verify') && $user->is('manager') && $province->user->parent_id == $user->id) { return true; } return false; } /** * Determine if the given user can approve the given province. * * @param User $user * @param Province $province * * @return bool */ public function approve(User $user, Province $province) { if ($user->canDo('k_b.province.approve') && $user->is('admin')) { 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; } } }