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