Reading content
The query layer every template, seeder, admin screen and API call reads and writes through.
There is one query layer, and HTTP is a transport over it. A template, a seeder, the admin and the API all call the same methods with the same arguments, so none of them is handed another shape or a weaker validation. Permissions are the same too, unless code passes overrideAccess: true.
Reads
Mainstay::find(Article::class, where: [...], sort: [...], limit: 10);
Mainstay::paginate(Article::class, perPage: 10);
Mainstay::findById(Article::class, $id);
Mainstay::findByUri('/blog/hello');
find() gives a collection and paginate() Laravel's paginator, with page: read from the request unless you pass it. Every read takes locale:, depth: and overrideAccess:; find() and paginate() take trashed: true for what is in the trash. Each hands back instances of your class, its fields cast: a date is a CarbonImmutable, an image a Media, a body a Document.
Filtering
where is data rather than a closure, so a query string can carry the same condition a template writes. A value alone means equal; an operator and a value say more:
Mainstay::find(Event::class, where: [
'kind' => 'workshop',
'price' => ['<=' => 20],
'startsAt' => ['>' => now()],
'id' => ['not_in' => [4, 9]],
]);
The operators are =, !=, <, <=, >, >=, in and not_in. A plain list is refused, since it could mean any or all; in says which. Only = and != take null. Besides fields, id, createdAt and updatedAt can be filtered and sorted on. A JSON field, a body or a list of blocks, is not filtered on.
Sorting
sort is a field, or a list of them, each with - in front to descend: sort: ['-publishedOn', 'title']. Entries without a value come last either way, on every database.
Writes
$article = Mainstay::create(Article::class, $data);
Mainstay::update(Article::class, $id, ['title' => 'Hello again']);
Mainstay::delete(Article::class, $id);
update() changes only the keys given. A write that does not validate throws Laravel's ValidationException naming each field; a query that cannot mean anything throws BadQuery saying why. create() and update() put content live at once; a change meant to wait is a draft.
Access
Every call asks Laravel's Gate about the account signed in to the admin. On a public page nobody is, and reading is open to everyone while writing is refused. Code that writes on its own authority, a seeder or an import, says so with overrideAccess: true, so a refusal is never silently skipped.