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