1 | <?php |
||
16 | class ModelManager |
||
17 | { |
||
18 | /** |
||
19 | * The base query builder instance. |
||
20 | * |
||
21 | * @var \Childish\query\Builder |
||
22 | */ |
||
23 | protected $query; |
||
24 | |||
25 | /** |
||
26 | * The model being queried. |
||
27 | * |
||
28 | * @var \Childish\ChildishModel |
||
29 | */ |
||
30 | protected $model; |
||
31 | |||
32 | /** |
||
33 | * The query union statements. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | public $unions; |
||
38 | /** |
||
39 | * The methods that should be returned from query builder. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $passthru = [ |
||
44 | 'insert', 'insertGetId', 'getBindings', 'toSql', |
||
45 | 'exists', 'count', 'min', 'max', 'avg', 'sum', 'getConnection', |
||
46 | ]; |
||
47 | |||
48 | |||
49 | /** |
||
50 | * Create a new Eloquent query builder instance. |
||
51 | * |
||
52 | * @param \Childish\query\Builder $query |
||
53 | * @return mixed|void |
||
|
|||
54 | */ |
||
55 | public function __construct(Builder $query) |
||
59 | |||
60 | /** |
||
61 | * Set a model instance for the model being queried. |
||
62 | * |
||
63 | * @param \Childish\ChildishModel $model |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function setModel(ChildishModel $model) |
||
74 | |||
75 | /** |
||
76 | * Get the model instance being queried. |
||
77 | * |
||
78 | * @return \Childish\ChildishModel |
||
79 | */ |
||
80 | public function getModel() |
||
84 | |||
85 | |||
86 | /** |
||
87 | * Add a basic where clause to the query. |
||
88 | * |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function where() |
||
96 | |||
97 | public function update($values) |
||
101 | |||
102 | /** |
||
103 | * Get a single column's value from the first result of a query. |
||
104 | * |
||
105 | * @param string $column |
||
106 | * @return mixed |
||
107 | */ |
||
108 | public function value($column) |
||
114 | |||
115 | /** |
||
116 | * Execute the query as a "select" statement. |
||
117 | * |
||
118 | * @param array $columns |
||
119 | * @return \Childish\support\Collection|static[]\ |
||
120 | */ |
||
121 | public function get($columns = ['*']) |
||
125 | |||
126 | /** |
||
127 | * Get the hydrated models without eager loading. |
||
128 | * |
||
129 | * @param array $columns |
||
130 | * @return \Childish\ChildishModel[] |
||
131 | */ |
||
132 | public function getModels($columns = ['*']) |
||
138 | |||
139 | /** |
||
140 | * Create a collection of models from plain arrays. |
||
141 | * |
||
142 | * @param array $items |
||
143 | * @return \Childish\support\Collection |
||
144 | */ |
||
145 | public function hydrate(array $items) |
||
153 | |||
154 | /** |
||
155 | * Create a new instance of the model being queried. |
||
156 | * |
||
157 | * @param array $attributes |
||
158 | * @return \Childish\ChildishModel |
||
159 | */ |
||
160 | public function newModelInstance($attributes = []) |
||
166 | |||
167 | |||
168 | /** |
||
169 | * Execute the query and get the first result. |
||
170 | * |
||
171 | * @param array $columns |
||
172 | * @return \Childish\ChildishModel|static|null |
||
173 | */ |
||
174 | public function first($columns = ['*']) |
||
178 | |||
179 | /** |
||
180 | * Alias to set the "limit" value of the query. |
||
181 | * |
||
182 | * @param int $value |
||
183 | * @return \Childish\query\Builder|static |
||
184 | */ |
||
185 | public function take($value) |
||
189 | |||
190 | /** |
||
191 | * Set the "limit" value of the query. |
||
192 | * |
||
193 | * @param int $value |
||
194 | * @return $this |
||
195 | */ |
||
196 | public function limit($value) |
||
206 | |||
207 | |||
208 | /** |
||
209 | * Get the underlying query builder instance. |
||
210 | * |
||
211 | * @return \Childish\query\Builder |
||
212 | */ |
||
213 | public function getQuery() |
||
217 | |||
218 | /** |
||
219 | * Set the underlying query builder instance. |
||
220 | * |
||
221 | * @param \Childish\query\Builder $query |
||
222 | * @return $this |
||
223 | */ |
||
224 | public function setQuery($query) |
||
230 | |||
231 | |||
232 | /** |
||
233 | * Add the "updated at" column to an array of values. |
||
234 | * |
||
235 | * @param array $values |
||
236 | * @return array |
||
237 | */ |
||
238 | protected function addUpdatedAtColumn(array $values) |
||
249 | |||
250 | /** |
||
251 | * Increment a column's value by a given amount. |
||
252 | * |
||
253 | * @param string $column |
||
254 | * @param int $amount |
||
255 | * @param array $extra |
||
256 | * @return int |
||
257 | */ |
||
258 | public function increment($column, $amount = 1, array $extra = []) |
||
264 | |||
265 | /** |
||
266 | * Delete a record from the database. |
||
267 | * |
||
268 | * @return mixed |
||
269 | */ |
||
270 | public function delete() |
||
274 | |||
275 | /** |
||
276 | * Dynamically handle calls into the query instance. |
||
277 | * |
||
278 | * @param string $method |
||
279 | * @param array $parameters |
||
280 | * @return mixed |
||
281 | */ |
||
282 | public function __call($method, $parameters) |
||
290 | |||
291 | /** |
||
292 | * Force a clone of the underlying query builder when cloning. |
||
293 | * |
||
294 | * @return void |
||
295 | */ |
||
296 | public function __clone() |
||
300 | } |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.