1 | <?php |
||
15 | abstract class BaseColumnFilter implements Renderable, ColumnFilterInterface, Arrayable |
||
16 | { |
||
17 | use SqlQueryOperators, HtmlAttributes, Assets, \SleepingOwl\Admin\Traits\Renderable; |
||
18 | |||
19 | /** |
||
20 | * @var \Closure|null |
||
21 | */ |
||
22 | protected $callback; |
||
23 | |||
24 | /** |
||
25 | * @var string|null |
||
26 | */ |
||
27 | protected $columnName; |
||
28 | |||
29 | 62 | public function __construct() |
|
33 | |||
34 | /** |
||
35 | * Initialize column filter. |
||
36 | */ |
||
37 | 3 | public function initialize() |
|
41 | |||
42 | /** |
||
43 | * @return null|string |
||
44 | */ |
||
45 | 40 | public function getColumnName() |
|
49 | |||
50 | /** |
||
51 | * @param null|string $name |
||
52 | * |
||
53 | * @return $this |
||
54 | */ |
||
55 | public function setColumnName($name) |
||
61 | |||
62 | /** |
||
63 | * @param mixed $value |
||
64 | * |
||
65 | * @return mixed |
||
66 | */ |
||
67 | 40 | public function parseValue($value) |
|
71 | |||
72 | /** |
||
73 | * @deprecated |
||
74 | * @return \Closure|null |
||
75 | */ |
||
76 | 40 | public function getCallback() |
|
80 | |||
81 | /** |
||
82 | * @param \Closure $callback |
||
83 | * @deprecated |
||
84 | * @return $this |
||
85 | */ |
||
86 | public function setCallback(\Closure $callback) |
||
92 | |||
93 | /** |
||
94 | * @param ColumnInterface $column |
||
95 | * @param Builder $query |
||
96 | * @param string $queryString |
||
97 | * @param array|string $queryParams |
||
98 | * |
||
99 | * @return void |
||
100 | */ |
||
101 | 40 | public function apply(ColumnInterface $column, Builder $query, $queryString, $queryParams) |
|
102 | { |
||
103 | 40 | $queryString = $this->parseValue($queryString); |
|
104 | |||
105 | 40 | if (($metaInstance = $column->getMetaData()) instanceof ColumnMetaInterface) { |
|
106 | if (method_exists($metaInstance, 'onFilterSearch')) { |
||
107 | $metaInstance->onFilterSearch($column, $query, $queryString, $queryParams); |
||
|
|||
108 | |||
109 | return; |
||
110 | } |
||
111 | } |
||
112 | |||
113 | 40 | if (is_callable($callback = $column->getFilterCallback())) { |
|
114 | $callback($column, $query, $queryString, $queryParams); |
||
115 | |||
116 | return; |
||
117 | } |
||
118 | |||
119 | 40 | if (is_callable($callback = $this->getCallback())) { |
|
120 | $callback($column, $query, $queryString, $queryParams); |
||
121 | |||
122 | return; |
||
123 | } |
||
124 | |||
125 | 40 | if (empty($queryString) && strlen($queryString) == 0) { |
|
126 | return; |
||
127 | } |
||
128 | |||
129 | 40 | if (is_null($name = $this->getColumnName())) { |
|
130 | 40 | $name = $column->getName(); |
|
131 | 40 | } |
|
132 | |||
133 | 40 | if (strpos($name, '.') !== false) { |
|
134 | 20 | $parts = explode('.', $name); |
|
135 | 20 | $fieldName = array_pop($parts); |
|
136 | 20 | $relationName = implode('.', $parts); |
|
137 | |||
138 | 20 | $query->whereHas($relationName, function ($q) use ($queryString, $fieldName) { |
|
139 | 20 | $this->buildQuery($q, $fieldName, $queryString); |
|
140 | 20 | }); |
|
141 | 20 | } else { |
|
142 | 20 | $this->buildQuery($query, $name, $queryString); |
|
143 | } |
||
144 | 40 | } |
|
145 | |||
146 | /** |
||
147 | * Get the instance as an array. |
||
148 | * |
||
149 | * @return array |
||
150 | */ |
||
151 | public function toArray() |
||
158 | } |
||
159 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.