-
app/Policies/UrlPolicy.php
Open in GitHubuse App\Models\Url; use App\Models\User; use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Support\Facades\Auth; class UrlPolicy { use HandlesAuthorization; public function forceDelete(User $user, Url $url) { return Auth::user()->hasRole('admin') || $user->id === $url->user_id; } public function updateUrl(User $user, Url $url) { return Auth::user()->hasRole('admin') || $user->id === $url->user_id; } }
-
app/Providers/AuthServiceProvider.php
Open in GitHubuse Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider { protected $policies = [ 'App\Models\Url' => 'App\Policies\UrlPolicy', ]; }