Support the ongoing development of Laravel.io →
Authorization Laravel Middleware
0
moderator

Hello @robg

What you described is what the documentation called Guest Users ( https://laravel.com/docs/10.x/authorization#guest-users ) The function need to get the user but it can nullable.

That means the policy view function should be:

    public function view(?User $user, Page $model): bool
    {
        dd(__METHOD__);
        return true;
    }
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Robert Gouveia robg Joined 17 Feb 2024

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.