1 | <?php |
||
18 | trait CustomOrderTrait |
||
19 | { |
||
20 | /** |
||
21 | * Check $order_fields and $order_defaults are set |
||
22 | * |
||
23 | * @param string $orderField |
||
24 | * @param string $direction |
||
25 | * @return bool |
||
26 | */ |
||
27 | protected function hasOrderFieldsAndDefaults($orderField, $direction) |
||
31 | |||
32 | /** |
||
33 | * Check $this->order_fields set correctly |
||
34 | * |
||
35 | * @return bool |
||
36 | */ |
||
37 | protected function hasOrderFields() |
||
41 | |||
42 | /** |
||
43 | * Check order defaults set correctly |
||
44 | * |
||
45 | * @param string $orderField |
||
46 | * @param string $direction |
||
47 | * @return bool |
||
48 | */ |
||
49 | protected function hasOrderDefaults($orderField, $direction) |
||
57 | |||
58 | /** |
||
59 | * Check $this->search_fields set correctly |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | protected function hasSearchFields() |
||
67 | |||
68 | /** |
||
69 | * @param string $attributeName |
||
70 | * @param bool $canBeEmpty |
||
71 | * @return bool |
||
72 | */ |
||
73 | protected function hasProperty($attributeName, $canBeEmpty = true) |
||
81 | |||
82 | /** |
||
83 | * Override column if provided column not valid |
||
84 | * |
||
85 | * @param string $column |
||
86 | * @return string |
||
87 | */ |
||
88 | protected function setOrderColumn($column) |
||
97 | |||
98 | /** |
||
99 | * Override direction if provided direction not valid |
||
100 | * |
||
101 | * @param string $direction |
||
102 | * @return string |
||
103 | */ |
||
104 | protected function setOrderDirection($direction) |
||
113 | |||
114 | /** |
||
115 | * Set order based on order_fields |
||
116 | * |
||
117 | * @param Builder $query |
||
118 | * @param string $column |
||
119 | * @param string $direction |
||
120 | * @return Builder |
||
121 | */ |
||
122 | protected function setOrder($query, $column, $direction) |
||
134 | |||
135 | /** |
||
136 | * Join a related table if not already joined |
||
137 | * |
||
138 | * @param Builder $query |
||
139 | * @param string $table |
||
140 | * @return Builder |
||
141 | */ |
||
142 | protected function joinRelatedTable($query, $table) |
||
159 | |||
160 | /** |
||
161 | * Check if this model has already been joined to a table or relation |
||
162 | * |
||
163 | * @param Builder $builder |
||
164 | * @param string $table |
||
165 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
166 | * @return bool |
||
167 | */ |
||
168 | protected function hasJoin(Builder $builder, $table, $relation) |
||
176 | |||
177 | /** |
||
178 | * Check if model is currently joined to $table |
||
179 | * |
||
180 | * @param Builder $builder |
||
181 | * @param string $table |
||
182 | * @return bool |
||
183 | */ |
||
184 | protected function isJoinedToTable(Builder $builder, $table) |
||
197 | |||
198 | /** |
||
199 | * Check if relation exists in eager loads |
||
200 | * |
||
201 | * @param Builder $builder |
||
202 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
203 | * @return bool |
||
204 | */ |
||
205 | protected function isEagerLoaded(Builder $builder, $relation) |
||
211 | } |
||
212 |