for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Policies;
use App\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class UserPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
* @param User $user
* @param $ability
* @return bool
*/
public function before(User $user, $ability)
$ability
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function before(User $user, /** @scrutinizer ignore-unused */ $ability)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
if ($user->isSuperAdmin()) {
return true;
}
return null;
// You can create a user if you are not a simple user
public function create(User $user)
if (!$user->isUser()) {
return false;
// You can store a user if you are not a simple user
public function store(User $user)
public function delete(User $user, User $userModel)
if ($user->isFederationPresident()) {
return $user->federationOwned->id == $userModel->federation_id;
if ($user->isAssociationPresident()) {
return $user->associationOwned->id == $userModel->association_id;
if ($user->isClubPresident()) {
return $user->clubOwned->id == $userModel->club_id;
public function edit(User $user, User $userModel)
if ($user->isUserOrMore()) {
return $user->id == $userModel->id;
public function update(User $user, User $userModel)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.