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