1 | <?php |
||
13 | abstract class Repository implements RepositoryInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var App |
||
17 | */ |
||
18 | private $app; |
||
19 | /** |
||
20 | * @var |
||
21 | */ |
||
22 | protected $model; |
||
23 | |||
24 | /** |
||
25 | * Repository constructor. |
||
26 | * |
||
27 | * @param App $app |
||
28 | */ |
||
29 | 28 | public function __construct(App $app) |
|
34 | |||
35 | /** |
||
36 | * @return mixed |
||
37 | */ |
||
38 | abstract public function model(); |
||
39 | |||
40 | /** |
||
41 | * @param array $columns |
||
42 | * |
||
43 | * @return mixed |
||
44 | */ |
||
45 | 9 | public function all($columns = ['*']) |
|
49 | |||
50 | /** |
||
51 | * @param int $perPage |
||
52 | * @param null $appends |
||
53 | * @param array $columns |
||
54 | * |
||
55 | * @return mixed |
||
56 | */ |
||
57 | public function allPaginated($perPage = 15, $appends = null, $columns = ['*']) |
||
61 | |||
62 | /** |
||
63 | * @param $field |
||
64 | * @param $value |
||
65 | * @param array $columns |
||
66 | * |
||
67 | * @return mixed |
||
68 | */ |
||
69 | 1 | public function search($field, $value, $columns = ['*']) |
|
73 | |||
74 | /** |
||
75 | * @param $field |
||
76 | * @param $value |
||
77 | * @param int $perPage |
||
78 | * @param null $appends |
||
79 | * @param array $columns |
||
80 | * |
||
81 | * @return mixed |
||
82 | */ |
||
83 | public function searchPaginated($field, $value, $perPage = 15, $appends = null, $columns = ['*']) |
||
87 | |||
88 | /** |
||
89 | * @param array $data |
||
90 | * |
||
91 | * @return mixed |
||
92 | */ |
||
93 | 3 | public function create(array $data) |
|
97 | |||
98 | /** |
||
99 | * @param array $data |
||
100 | * @param $id |
||
101 | * @param string $attribute |
||
102 | * |
||
103 | * @return mixed |
||
104 | */ |
||
105 | 5 | public function update(array $data, $id, $attribute = 'id') |
|
109 | |||
110 | /** |
||
111 | * @param array $data |
||
112 | * @param $model |
||
113 | * |
||
114 | * @return mixed |
||
115 | */ |
||
116 | public function updateFillable(array $data, $model) |
||
122 | |||
123 | /** |
||
124 | * @param $id |
||
125 | * |
||
126 | * @return mixed |
||
127 | */ |
||
128 | 4 | public function delete($id) |
|
132 | |||
133 | /** |
||
134 | * @param $id |
||
135 | * @param array $columns |
||
136 | * |
||
137 | * @return mixed |
||
138 | */ |
||
139 | 11 | public function findOrFail($id, $columns = ['*']) |
|
143 | |||
144 | /** |
||
145 | * @param $attribute |
||
146 | * @param $value |
||
147 | * @param array $columns |
||
148 | * |
||
149 | * @return mixed |
||
150 | */ |
||
151 | 1 | public function findBy($attribute, $value, $columns = ['*']) |
|
155 | |||
156 | /** |
||
157 | * @throws RepositoryException |
||
158 | * |
||
159 | * @return Model|mixed |
||
160 | */ |
||
161 | 28 | public function makeModel() |
|
170 | } |
||
171 |