@@ -30,51 +30,64 @@ |
||
| 30 | 30 | |
| 31 | 31 | foreach($table->columns() as $column_name => $column) |
| 32 | 32 | { |
| 33 | - if(isset($filters[$column_name]) && is_string($filters[$column_name])) |
|
| 34 | - $Query->aw_eq($column_name, $filters[$column_name]); |
|
| 33 | + if(isset($filters[$column_name]) && is_string($filters[$column_name])) { |
|
| 34 | + $Query->aw_eq($column_name, $filters[$column_name]); |
|
| 35 | + } |
|
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | if(is_subclass_of($event = new $class(), '\HexMakina\kadro\Models\Interfaces\EventInterface')) |
| 38 | 39 | { |
| 39 | - if(!empty($filters['date_start'])) |
|
| 40 | - $Query->aw_gte($event->event_field(), $filters['date_start'], $Query->table_label(), ':filter_date_start'); |
|
| 40 | + if(!empty($filters['date_start'])) { |
|
| 41 | + $Query->aw_gte($event->event_field(), $filters['date_start'], $Query->table_label(), ':filter_date_start'); |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | - if(!empty($filters['date_stop'])) |
|
| 43 | - $Query->aw_lte($event->event_field(), $filters['date_stop'], $Query->table_label(), ':filter_date_stop'); |
|
| 44 | + if(!empty($filters['date_stop'])) { |
|
| 45 | + $Query->aw_lte($event->event_field(), $filters['date_stop'], $Query->table_label(), ':filter_date_stop'); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | - if(empty($options['order_by'])) |
|
| 46 | - $Query->order_by([$event->event_field(), 'DESC']); |
|
| 48 | + if(empty($options['order_by'])) { |
|
| 49 | + $Query->order_by([$event->event_field(), 'DESC']); |
|
| 50 | + } |
|
| 47 | 51 | } |
| 48 | 52 | |
| 49 | - if(isset($filters['content'])) $Query->aw_filter_content($filters['content']); |
|
| 53 | + if(isset($filters['content'])) { |
|
| 54 | + $Query->aw_filter_content($filters['content']); |
|
| 55 | + } |
|
| 50 | 56 | |
| 51 | 57 | if(isset($filters['ids'])) |
| 52 | 58 | { |
| 53 | - if(empty($filters['ids'])) |
|
| 54 | - $Query->and_where('1=0'); // TODO: this is a new low.. find another way to cancel query |
|
| 55 | - else $Query->aw_numeric_in('id', $filters['ids'], $Query->table_label()); |
|
| 59 | + if(empty($filters['ids'])) { |
|
| 60 | + $Query->and_where('1=0'); |
|
| 61 | + } |
|
| 62 | + // TODO: this is a new low.. find another way to cancel query |
|
| 63 | + else { |
|
| 64 | + $Query->aw_numeric_in('id', $filters['ids'], $Query->table_label()); |
|
| 65 | + } |
|
| 56 | 66 | } |
| 57 | 67 | |
| 58 | - if(isset($options['order_by'])) // TODO commenting required about the array situation |
|
| 68 | + if(isset($options['order_by'])) { |
|
| 69 | + // TODO commenting required about the array situation |
|
| 59 | 70 | { |
| 60 | 71 | $order_by = $options['order_by']; |
| 72 | + } |
|
| 61 | 73 | |
| 62 | - if(is_string($order_by)) |
|
| 63 | - $Query->order_by($order_by); |
|
| 64 | - |
|
| 65 | - elseif(is_array($order_by)) |
|
| 66 | - foreach($options['order_by'] as $order_by) |
|
| 74 | + if(is_string($order_by)) { |
|
| 75 | + $Query->order_by($order_by); |
|
| 76 | + } elseif(is_array($order_by)) { |
|
| 77 | + foreach($options['order_by'] as $order_by) |
|
| 67 | 78 | { |
| 68 | 79 | if(!isset($order_by[2])) |
| 69 | 80 | array_unshift($order_by, ''); |
| 81 | + } |
|
| 70 | 82 | |
| 71 | 83 | list($order_table, $order_field, $order_direction) = $order_by; |
| 72 | 84 | $Query->order_by([$order_table ?? '', $order_field, $order_direction]); |
| 73 | 85 | } |
| 74 | 86 | } |
| 75 | 87 | |
| 76 | - if(isset($options['limit']) && is_array($options['limit'])) |
|
| 77 | - $Query->limit($options['limit'][1], $options['limit'][0]); |
|
| 88 | + if(isset($options['limit']) && is_array($options['limit'])) { |
|
| 89 | + $Query->limit($options['limit'][1], $options['limit'][0]); |
|
| 90 | + } |
|
| 78 | 91 | |
| 79 | 92 | return $Query; |
| 80 | 93 | } |