Initial Commit

This commit is contained in:
dann4624
2022-09-28 09:38:08 +02:00
parent cac476f80f
commit 2d04a269e6
355 changed files with 52166 additions and 25 deletions
+61
View File
@@ -0,0 +1,61 @@
<?php
namespace App\Policies;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class PDFPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine whether the user can view any models.
*
* @return Response
*/
public function viewAny(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','pdf_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can update the model.
*
* @return Response
*/
public function view(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','pdf_view'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
/**
* Determine whether the user can delete the model.
*
* @return Response
*/
public function delete(): Response
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','pdf_delete'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}