Digging Deeper

Scout integration

Secure your Laravel Scout queries, the easy way!
You first need to install and configure Laravel Scout on your project

Scout Query

You have a scoutQuery method you can call directly on your defined perimeters in your control class. This works the same as the query, but you instead receive a Scout Builder instance.

use Laravel\Scout\Builder;

class TaskControl extends Control
{
    protected function perimeters(): array
    {
        return [
            GlobalPerimeter::new()
                ->allowed(function (Model $user, string $method) {
                    // ...
                })
                ->scoutQuery(function (Builder $query, Model $user) {
                    return $query;
                })
        ];
    }
}

Usage

You need to call the controlled method on your Scout Builder to apply your access control rules:

App\Models\Post::search('Laravel Access Control')
    ->controlled() // This applies the access control rules
    ->get();