The method hasPermissionTo() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of Illuminate\Contracts\Auth\Authenticatable such as Illuminate\Foundation\Auth\User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
11
if (!Auth::user()->/** @scrutinizer ignore-call */ hasPermissionTo($permissionName)) {
Loading history...
12
throw new AccessDeniedException("You have not the permission to view this page", 403);
13
}
14
}
15
16
/**
17
* Check permmission and also allows the owner of the model.
18
**/
19
public function checkPermissionAllowOwner(string $permissionName, $entity)
20
{
21
$userId = $entity->user_id ?? 'none';
22
23
if (!( Auth::user()->hasPermissionTo($permissionName) || Auth::id() === $userId)) {
24
throw new AccessDeniedException("You have not the permission to view this page", 403);