<?php namespace Bixo\Aml\Policies; use Illuminate\Foundation\Auth\User as Authenticatable; use Bixo\Aml\Models\Nationality; class NationalityPolicy { use NationalityAction; use NationalityReport; use NationalityWorkflow; /** * Determine if the given user can view the nationality. * * @param Authenticatable $user * @param Nationality $nationality * * @return bool */ public function view(Authenticatable $user, Nationality $nationality) { if ($authUser->canDo('aml.nationality.view') && $authUser->isAdmin() || $user->isClient()) { return true; } return $nationality->is_owner; } /** * Determine if the given user can create a nationality. * * @param Authenticatable $user * * @return bool */ public function create(Authenticatable $user) { return $authUser->canDo('aml.nationality.create'); } /** * Determine if the given user can update the given nationality. * * @param Authenticatable $user * @param Nationality $nationality * * @return bool */ public function update(Authenticatable $user, Nationality $nationality) { if ($user->canDo('aml.nationality.edit') && $user->isAdmin()) { return true; } return $nationality->is_owner; } /** * Determine if the given user can delete the given nationality. * * @param Authenticatable $user * * @return bool */ public function destroy(Authenticatable $user, Nationality $nationality) { return $nationality->is_owner; } /** * 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; } } }