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