2021-02-02 06:40:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
|
|
use App\Models\ServiceTemplate;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
|
|
|
|
|
|
class ServiceTemplatePolicy
|
|
|
|
|
{
|
|
|
|
|
use HandlesAuthorization;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can view any service templates.
|
|
|
|
|
*
|
2021-09-08 23:35:56 +02:00
|
|
|
* @param \App\Models\User $user
|
2021-02-02 06:40:11 +00:00
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function viewAny(User $user): bool
|
2021-02-02 06:40:11 +00:00
|
|
|
{
|
|
|
|
|
return $user->hasGlobalRead();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can view the service template.
|
|
|
|
|
*
|
2021-09-08 23:35:56 +02:00
|
|
|
* @param \App\Models\User $user
|
|
|
|
|
* @param \App\Models\ServiceTemplate $template
|
2021-02-02 06:40:11 +00:00
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function view(User $user, ServiceTemplate $template): bool
|
2021-02-02 06:40:11 +00:00
|
|
|
{
|
|
|
|
|
return $this->viewAny($user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can create service templates.
|
|
|
|
|
*
|
2021-09-08 23:35:56 +02:00
|
|
|
* @param \App\Models\User $user
|
2021-02-02 06:40:11 +00:00
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function create(User $user): bool
|
2021-02-02 06:40:11 +00:00
|
|
|
{
|
|
|
|
|
return $user->hasGlobalAdmin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can update the service template.
|
|
|
|
|
*
|
2021-09-08 23:35:56 +02:00
|
|
|
* @param \App\Models\User $user
|
|
|
|
|
* @param \App\Models\ServiceTemplate $template
|
2021-02-02 06:40:11 +00:00
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function update(User $user, ServiceTemplate $template): bool
|
2021-02-02 06:40:11 +00:00
|
|
|
{
|
|
|
|
|
return $user->isAdmin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can delete the service template.
|
|
|
|
|
*
|
2021-09-08 23:35:56 +02:00
|
|
|
* @param \App\Models\User $user
|
|
|
|
|
* @param \App\Models\ServiceTemplate $template
|
2021-02-02 06:40:11 +00:00
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function delete(User $user, ServiceTemplate $template): bool
|
2021-02-02 06:40:11 +00:00
|
|
|
{
|
|
|
|
|
return $user->isAdmin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can restore the service template.
|
|
|
|
|
*
|
2021-09-08 23:35:56 +02:00
|
|
|
* @param \App\Models\User $user
|
|
|
|
|
* @param \App\Models\ServiceTemplate $template
|
2021-02-02 06:40:11 +00:00
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function restore(User $user, ServiceTemplate $template): bool
|
2021-02-02 06:40:11 +00:00
|
|
|
{
|
|
|
|
|
return $user->hasGlobalAdmin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can permanently delete the service template.
|
|
|
|
|
*
|
2021-09-08 23:35:56 +02:00
|
|
|
* @param \App\Models\User $user
|
|
|
|
|
* @param \App\Models\ServiceTemplate $template
|
2021-02-02 06:40:11 +00:00
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function forceDelete(User $user, ServiceTemplate $template): bool
|
2021-02-02 06:40:11 +00:00
|
|
|
{
|
|
|
|
|
return $user->isAdmin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can view the stored configuration of the service template
|
|
|
|
|
* from Oxidized or Rancid
|
|
|
|
|
*
|
2021-09-08 23:35:56 +02:00
|
|
|
* @param \App\Models\User $user
|
|
|
|
|
* @param \App\Models\ServiceTemplate $template
|
2021-02-02 06:40:11 +00:00
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function showConfig(User $user, ServiceTemplate $template): bool
|
2021-02-02 06:40:11 +00:00
|
|
|
{
|
|
|
|
|
return $user->isAdmin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can update service template notes.
|
|
|
|
|
*
|
2021-09-08 23:35:56 +02:00
|
|
|
* @param \App\Models\User $user
|
|
|
|
|
* @param \App\Models\ServiceTemplate $template
|
2021-02-02 06:40:11 +00:00
|
|
|
*/
|
2023-05-24 22:21:54 +02:00
|
|
|
public function updateNotes(User $user, ServiceTemplate $template): bool
|
2021-02-02 06:40:11 +00:00
|
|
|
{
|
|
|
|
|
return $user->isAdmin();
|
|
|
|
|
}
|
|
|
|
|
}
|