Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Policies not found using Gate::authorize() #225

Closed
bakerkretzmar opened this issue Jan 30, 2025 · 2 comments
Closed

[Bug]: Policies not found using Gate::authorize() #225

bakerkretzmar opened this issue Jan 30, 2025 · 2 comments
Assignees
Labels

Comments

@bakerkretzmar
Copy link

bakerkretzmar commented Jan 30, 2025

Extension Version

0.1.18

PHP Binary

Valet

Operating System

macOS

What happened?

All references to my policies using Gate::authorize() give a 'not found' error message. The error message seems to indicate that the extension is looking for a policy with a name matching the method I'm trying to call on it.

E.g. this code in a controller:

Gate::authorize('update', $program);

Results in a lint (squiggly underline, no link/reference) with the message "Policy [update] not found."

My setup is completely vanilla in regards to auth/policies/controllers—Program is a regular model, ProgramPolicy exists in the default location and has an update method, etc.

I can reproduce this in a new Laravel 11 app too after running php artisan make:policy UserPolicy --model=User and php artisan make:controller UserController --model=User and adding Gate::authorize('create', User::class);.

Mimimal Code Sample

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Support\Facades\Gate;

class UserController extends Controller
{
    public function create()
    {
        Gate::authorize('create', User::class);
    }
}
@bakerkretzmar bakerkretzmar changed the title [Bug]: Policy not found using Gate::authorize() [Bug]: Policies not found using Gate::authorize() Jan 30, 2025
@joetannenbaum
Copy link
Collaborator

This should be fixed in the latest release (v0.1.20). If you are still experiencing this issue feel free to re-open.

@bakerkretzmar
Copy link
Author

Thanks! Not seeing this specific issue anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants