-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathResourceContext.php
57 lines (47 loc) · 1.31 KB
/
ResourceContext.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace Mblarsen\LaravelRepository;
use Illuminate\Database\Eloquent\Model;
interface ResourceContext
{
/**
* An associative array where keys are properties and values are queries.
*/
public function filters(): array;
/**
* Get the current page
*/
public function page(): int;
/**
* Determine whether a full or paginated query is requested.
*/
public function paginate(): bool;
/**
* Number of entities per page.
*/
public function perPage(): int;
/**
* A tuple withe [column, direction], eg. [created_at, desc]
*
* @return string[]
*/
public function sortBy(): array;
/**
* Convert the context to an array. Optionally pass in a guard name to
* specify where to get the user from.
*
* @param string|null $guard The name of a guard. E.g. 'api'.
* @return array<string,mixed>
*/
public function toArray($guard = null): array;
/**
* Get the current user if any. Optionally pass in a guard name to
* specify where to get the user from.
*
* @param string|null $guard The name of a guard. E.g. 'api'.
*/
public function user($guard = null): ?Model;
/**
* An array of relationships to include in the query.
*/
public function with(): array;
}