1 | <?php |
||
11 | class Model |
||
12 | { |
||
13 | /** |
||
14 | * Eloquent model instance of the grid model. |
||
15 | * |
||
16 | * @var EloquentModel |
||
17 | */ |
||
18 | protected $model; |
||
19 | |||
20 | /** |
||
21 | * Array of queries of the eloquent model. |
||
22 | * |
||
23 | * @var \Illuminate\Support\Collection |
||
24 | */ |
||
25 | protected $queries; |
||
26 | |||
27 | /** |
||
28 | * Sort parameters of the model. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $sort; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $data = []; |
||
38 | |||
39 | /* |
||
40 | * 20 items per page as default. |
||
41 | * |
||
42 | * @var int |
||
43 | */ |
||
44 | protected $perPage = 20; |
||
45 | |||
46 | /** |
||
47 | * If the model use pagination. |
||
48 | * |
||
49 | * @var bool |
||
50 | */ |
||
51 | protected $usePaginate = true; |
||
52 | |||
53 | /** |
||
54 | * The query string variable used to store the per-page. |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $perPageName = 'per_page'; |
||
59 | |||
60 | /** |
||
61 | * The query string variable used to store the sort. |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $sortName = '_sort'; |
||
66 | |||
67 | /** |
||
68 | * Create a new grid model instance. |
||
69 | * |
||
70 | * @param EloquentModel $model |
||
71 | */ |
||
72 | public function __construct(EloquentModel $model) |
||
78 | |||
79 | /** |
||
80 | * Get the eloquent model of the grid model. |
||
81 | * |
||
82 | * @return EloquentModel |
||
83 | */ |
||
84 | public function eloquent() |
||
88 | |||
89 | /** |
||
90 | * Enable or disable pagination. |
||
91 | * |
||
92 | * @param bool $use |
||
93 | */ |
||
94 | public function usePaginate($use = true) |
||
98 | |||
99 | /** |
||
100 | * Get the query string variable used to store the per-page. |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | public function getPerPageName() |
||
108 | |||
109 | /** |
||
110 | * Set the query string variable used to store the per-page. |
||
111 | * |
||
112 | * @param string $name |
||
113 | * |
||
114 | * @return $this |
||
115 | */ |
||
116 | public function setPerPageName($name) |
||
122 | |||
123 | /** |
||
124 | * Get the query string variable used to store the sort. |
||
125 | * |
||
126 | * @return string |
||
127 | */ |
||
128 | public function getSortName() |
||
132 | |||
133 | /** |
||
134 | * Set the query string variable used to store the sort. |
||
135 | * |
||
136 | * @param string $name |
||
137 | * |
||
138 | * @return $this |
||
139 | */ |
||
140 | public function setSortName($name) |
||
146 | |||
147 | /** |
||
148 | * Build. |
||
149 | * |
||
150 | * @return array |
||
151 | */ |
||
152 | public function buildData() |
||
160 | |||
161 | /** |
||
162 | * Add conditions to grid model. |
||
163 | * |
||
164 | * @param array $conditions |
||
165 | * |
||
166 | * @return void |
||
167 | */ |
||
168 | public function addConditions(array $conditions) |
||
174 | |||
175 | /** |
||
176 | * Get table of the model. |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | public function getTable() |
||
184 | |||
185 | /** |
||
186 | * @throws \Exception |
||
187 | * |
||
188 | * @return Collection |
||
189 | */ |
||
190 | protected function get() |
||
213 | |||
214 | /** |
||
215 | * Set the grid paginate. |
||
216 | * |
||
217 | * @return void |
||
218 | */ |
||
219 | protected function setPaginate() |
||
241 | |||
242 | /** |
||
243 | * Resolve perPage for pagination. |
||
244 | * |
||
245 | * @param array|null $paginate |
||
246 | * |
||
247 | * @return array |
||
248 | */ |
||
249 | protected function resolvePerPage($paginate) |
||
266 | |||
267 | /** |
||
268 | * Find query by method name. |
||
269 | * |
||
270 | * @param $method |
||
271 | * |
||
272 | * @return static |
||
273 | */ |
||
274 | protected function findQueryByMethod($method) |
||
280 | |||
281 | /** |
||
282 | * Set the grid sort. |
||
283 | * |
||
284 | * @return void |
||
285 | */ |
||
286 | protected function setSort() |
||
308 | |||
309 | /** |
||
310 | * Set relation sort. |
||
311 | * |
||
312 | * @param string $column |
||
313 | * |
||
314 | * @return void |
||
315 | */ |
||
316 | protected function setRelationSort($column) |
||
341 | |||
342 | /** |
||
343 | * Reset orderBy query. |
||
344 | * |
||
345 | * @return void |
||
346 | */ |
||
347 | public function resetOrderBy() |
||
353 | |||
354 | /** |
||
355 | * Build join parameters. |
||
356 | * |
||
357 | * @param Relation $relation |
||
358 | * |
||
359 | * @return array |
||
360 | */ |
||
361 | protected function joinParameters(Relation $relation) |
||
370 | |||
371 | /** |
||
372 | * @param string $method |
||
373 | * @param array $arguments |
||
374 | * |
||
375 | * @return $this |
||
376 | */ |
||
377 | public function __call($method, $arguments) |
||
386 | |||
387 | /** |
||
388 | * @param $key |
||
389 | * |
||
390 | * @return mixed |
||
391 | */ |
||
392 | public function __get($key) |
||
400 | } |
||
401 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: