-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueryBuilderInterface.php
83 lines (72 loc) · 1.69 KB
/
QueryBuilderInterface.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
declare(strict_types=1);
namespace Pandawa\Contracts\Eloquent;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection as ModelCollection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
/**
* @template TModel
*
* @mixin Builder
*
* @author Iqbal Maulana <iq.bluejack@gmail.com>
*/
interface QueryBuilderInterface
{
/**
* Set the model to query builder.
*
* @param TModel $model
*
* @return static
*/
public function setModel(Model $model): static;
/**
* Set cache enabled or disabled.
*
* @param bool $enabled
*
* @return static
*/
public function enableCache(bool $enabled = true): static;
/**
* Apply criteria to query.
*
* @param CriterionInterface|array $criteria
*
* @return static
*/
public function withCriteria(CriterionInterface|array $criteria): static;
/**
* Get the model.
*
* @return TModel
*/
public function getModel(): Model;
/**
* @param array $columns
*
* @return Collection<TModel>|ModelCollection<TModel>
*/
public function get(array $columns = ['*']): Collection|ModelCollection;
/**
* @return LazyCollection<TModel>
*/
public function cursor(): LazyCollection;
/**
* Find the model by primary key.
*
* @param int|string $key
*
* @return TModel|null
*/
public function findByKey(int|string $key): ?Model;
/**
* @param array $columns
*
* @return TModel|null
*/
public function first(array $columns = ['*']): ?Model;
}