]> BookStack Code Mirror - bookstack/blob - app/Entities/Queries/ProvidesEntityQueries.php
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / app / Entities / Queries / ProvidesEntityQueries.php
1 <?php
2
3 namespace BookStack\Entities\Queries;
4
5 use BookStack\Entities\Models\Entity;
6 use Illuminate\Database\Eloquent\Builder;
7
8 /**
9  * Interface for our classes which provide common queries for our
10  * entity objects. Ideally all queries for entities should run through
11  * these classes.
12  * Any added methods should return a builder instances to allow extension
13  * via building on the query, unless the method starts with 'find'
14  * in which case an entity object should be returned.
15  * (nullable unless it's a *OrFail method).
16  */
17 interface ProvidesEntityQueries
18 {
19     /**
20      * Start a new query for this entity type.
21      */
22     public function start(): Builder;
23
24     /**
25      * Find the entity of the given ID, or return null if not found.
26      */
27     public function findVisibleById(int $id): ?Entity;
28
29     /**
30      * Start a query for items that are visible, with selection
31      * configured for list display of this item.
32      */
33     public function visibleForList(): Builder;
34 }