Files
einundzwanzig-portal/app/Policies/CountryPolicy.php
HolgerHatGarKeineNode 21fa8f7ed7 allow custom countries
2023-12-08 17:33:54 +01:00

84 lines
2.1 KiB
PHP

<?php
namespace App\Policies;
use App\Models\Country;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class CountryPolicy extends BasePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function viewAny(User $user): bool
{
return true;
}
/**
* Determine whether the user can view the model.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function view(User $user, Country $country): bool
{
return true;
}
/**
* Determine whether the user can create models.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function create(User $user): bool
{
dd($user);
return $user->can((new \ReflectionClass($this))->getShortName().'.'.__FUNCTION__);
}
/**
* Determine whether the user can update the model.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function update(User $user, Country $country): bool
{
return $user->can((new \ReflectionClass($this))->getShortName().'.'.__FUNCTION__);
}
/**
* Determine whether the user can delete the model.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function delete(User $user, Country $country): bool
{
return $user->can((new \ReflectionClass($this))->getShortName().'.'.__FUNCTION__);
}
/**
* Determine whether the user can restore the model.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function restore(User $user, Country $country): bool
{
return $user->can((new \ReflectionClass($this))->getShortName().'.'.__FUNCTION__);
}
/**
* Determine whether the user can permanently delete the model.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function forceDelete(User $user, Country $country): bool
{
return $user->can((new \ReflectionClass($this))->getShortName().'.'.__FUNCTION__);
}
}