๐Ÿ”’ Auth / Gates / Policies

Authentication state, Gate checks, Policy authorization

Auth State

Auth::check() false
Auth::guest() true
Auth::id() null
Auth::user()->name null
Login to see Gate results

// Gates โ€” AppServiceProvider::boot()

Gate::define('demo-gate', fn($u) => true);

// Check

Gate::check('demo-gate'); // bool

Gate::authorize('demo-gate'); // throws

$user->can('demo-gate');

// Policy โ€” PostPolicy

public function update(User $u, Post $p): bool

{ return $u->id === $p->user_id; }

// Controller

$this->authorize('update', $post);

// Blade

@can('update', $post) ... @endcan

Blade Auth Directives

โœ“ Inside @guest block

โœ— @can('update', $post) โ€” denied (login as post owner)