You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know if it's a bug. I have a custom user (tmeUser). I use two types of sessions, the other being the one that comes by default in Laravel (user). When I create a policy, I indicate that tmeUser has to arrive, but I always get the same error.
Steps To Reproduce
When I create a policy, I indicate that tmeUser has to arrive
App\Policies\PhrasePolicy::view(): Argument #1 ($tmeUser) must be of type App\Models\TmeUser, App\Models\User given, called in .....\laravel\vendor\laravel\framework\src\Illuminate\Auth\Access\Gate.php on line 816
In Laravel 10 and earlier there has never been any problem, tmeUser always came up. I have created the same project in Laravel 11 and I am encountering this problem.
The text was updated successfully, but these errors were encountered:
How are you using the policy? In the "can" middleware? Are you calling $tmeUser->can('view', $phrase) directly? Or using Gate::authorize('view', $phrase)?
Using an express call to tmeUser from the controller I have managed to get tmeUser to the policy
if (Gate::forUser(tmeUser)->denies('pass', $phrase)) {
abort(403);
}
So I guess it can be closed because there are ways to solve it.
I would appreciate it if someone could tell me if it would be possible to call the policy using middleware in routes.php as I have done in previous versions of Laravel.
Laravel Version
11.36.1
PHP Version
8.3.15
Database Driver & Version
10.4.32-MariaDB Windows 10
Description
I don't know if it's a bug. I have a custom user (tmeUser). I use two types of sessions, the other being the one that comes by default in Laravel (user). When I create a policy, I indicate that tmeUser has to arrive, but I always get the same error.
Steps To Reproduce
When I create a policy, I indicate that tmeUser has to arrive
But I always get the error:
App\Policies\PhrasePolicy::view(): Argument #1 ($tmeUser) must be of type App\Models\TmeUser, App\Models\User given, called in .....\laravel\vendor\laravel\framework\src\Illuminate\Auth\Access\Gate.php on line 816
In Laravel 10 and earlier there has never been any problem, tmeUser always came up. I have created the same project in Laravel 11 and I am encountering this problem.
The text was updated successfully, but these errors were encountered: