for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Policies;
use App\Models\EquipmentCategory;
use App\Models\User;
use App\Models\UserRolePermissions;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Support\Facades\Log;
class EquipmentCategoryPolicy
{
use HandlesAuthorization;
/*
* Allow anyone with "Manage Equipment" permission
*/
public function before(User $user, $method)
$allowed = UserRolePermissions::whereRoleId($user->role_id)->whereHas('UserRolePermissionTypes', function($q)
$q->where('description', 'Manage Equipment');
})->first();
Log::channel('auth')->debug('User '.$user->username.' is checking User Policy access to '.$method.'. Result - '.($allowed->allow ? 'Allow' : 'Deny'));
if($allowed->allow)
return $allowed->allow;
}
/**
* Determine whether the user can create models.
*
* @param \App\Models\User $user
* @return mixed
public function create(User $user)
$user
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function create(/** @scrutinizer ignore-unused */ User $user)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return false;
* Determine whether the user can update the model.
* @param \App\Models\EquipmentCategory $equipmentCategory
public function update(User $user, EquipmentCategory $equipmentCategory)
$equipmentCategory
public function update(User $user, /** @scrutinizer ignore-unused */ EquipmentCategory $equipmentCategory)
public function update(/** @scrutinizer ignore-unused */ User $user, EquipmentCategory $equipmentCategory)
* Determine whether the user can delete the model.
public function delete(User $user, EquipmentCategory $equipmentCategory)
public function delete(/** @scrutinizer ignore-unused */ User $user, EquipmentCategory $equipmentCategory)
public function delete(User $user, /** @scrutinizer ignore-unused */ EquipmentCategory $equipmentCategory)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.