2020-06-08 08:27:03 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
use App\Models\PollerCluster;
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
|
|
|
|
class PollerClusterPolicy
|
|
|
|
{
|
|
|
|
use HandlesAuthorization;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can view any poller clusters.
|
|
|
|
*
|
|
|
|
* @param \App\Models\User $user
|
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function viewAny(User $user): bool
|
2020-06-08 08:27:03 -05:00
|
|
|
{
|
|
|
|
return $user->hasGlobalAdmin();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can view the poller cluster.
|
|
|
|
*
|
|
|
|
* @param \App\Models\User $user
|
|
|
|
* @param \App\Models\PollerCluster $pollerCluster
|
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function view(User $user, PollerCluster $pollerCluster): bool
|
2020-06-08 08:27:03 -05:00
|
|
|
{
|
2023-05-24 22:21:54 +02:00
|
|
|
return $this->viewAny($user);
|
2020-06-08 08:27:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can create poller clusters.
|
|
|
|
*
|
|
|
|
* @param \App\Models\User $user
|
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function create(User $user): bool
|
2020-06-08 08:27:03 -05:00
|
|
|
{
|
2023-05-24 22:21:54 +02:00
|
|
|
return $this->viewAny($user);
|
2020-06-08 08:27:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can update the poller cluster.
|
|
|
|
*
|
|
|
|
* @param \App\Models\User $user
|
|
|
|
* @param \App\Models\PollerCluster $pollerCluster
|
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function update(User $user, PollerCluster $pollerCluster): bool
|
2020-06-08 08:27:03 -05:00
|
|
|
{
|
|
|
|
return $user->isAdmin();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can delete the poller cluster.
|
|
|
|
*
|
|
|
|
* @param \App\Models\User $user
|
|
|
|
* @param \App\Models\PollerCluster $pollerCluster
|
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function delete(User $user, PollerCluster $pollerCluster): bool
|
2020-06-08 08:27:03 -05:00
|
|
|
{
|
|
|
|
return $user->isAdmin();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can restore the poller cluster.
|
|
|
|
*
|
|
|
|
* @param \App\Models\User $user
|
|
|
|
* @param \App\Models\PollerCluster $pollerCluster
|
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function restore(User $user, PollerCluster $pollerCluster): bool
|
2020-06-08 08:27:03 -05:00
|
|
|
{
|
2023-05-24 22:21:54 +02:00
|
|
|
return $this->viewAny($user);
|
2020-06-08 08:27:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can permanently delete the poller cluster.
|
|
|
|
*
|
|
|
|
* @param \App\Models\User $user
|
|
|
|
* @param \App\Models\PollerCluster $pollerCluster
|
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function forceDelete(User $user, PollerCluster $pollerCluster): bool
|
2020-06-08 08:27:03 -05:00
|
|
|
{
|
2023-05-24 22:21:54 +02:00
|
|
|
return $this->viewAny($user);
|
2020-06-08 08:27:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can manage the poller cluster.
|
|
|
|
*
|
|
|
|
* @param \App\Models\User $user
|
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function manage(User $user): bool
|
2020-06-08 08:27:03 -05:00
|
|
|
{
|
|
|
|
return $user->isAdmin();
|
|
|
|
}
|
|
|
|
}
|