2024-02-05 10:59:20 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Entities\Queries;
|
|
|
|
|
2024-02-07 10:09:16 -05:00
|
|
|
use BookStack\Entities\Models\Entity;
|
2024-02-05 10:59:20 -05:00
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
|
2024-02-05 12:35:49 -05:00
|
|
|
/**
|
|
|
|
* Interface for our classes which provide common queries for our
|
|
|
|
* entity objects. Ideally all queries for entities should run through
|
|
|
|
* these classes.
|
|
|
|
* Any added methods should return a builder instances to allow extension
|
|
|
|
* via building on the query, unless the method starts with 'find'
|
|
|
|
* in which case an entity object should be returned.
|
|
|
|
* (nullable unless it's a *OrFail method).
|
|
|
|
*/
|
2024-02-05 10:59:20 -05:00
|
|
|
interface ProvidesEntityQueries
|
|
|
|
{
|
2024-02-07 17:41:45 -05:00
|
|
|
/**
|
|
|
|
* Start a new query for this entity type.
|
|
|
|
*/
|
2024-02-05 10:59:20 -05:00
|
|
|
public function start(): Builder;
|
2024-02-07 17:41:45 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the entity of the given ID, or return null if not found.
|
|
|
|
*/
|
2024-02-05 10:59:20 -05:00
|
|
|
public function findVisibleById(int $id): ?Entity;
|
2024-02-07 17:41:45 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Start a query for items that are visible, with selection
|
|
|
|
* configured for list display of this item.
|
|
|
|
*/
|
|
|
|
public function visibleForList(): Builder;
|
2024-02-05 10:59:20 -05:00
|
|
|
}
|