Customer.php
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace ACA\WC\Search\Order;
use AC;
use ACA\WC\Search;
use ACP;
use ACP\Search\Operators;
use ACP\Search\Value;
class Customer extends ACP\Search\Comparison implements ACP\Search\Comparison\SearchableValues
{
public function __construct()
{
parent::__construct(
new Operators([
Operators::EQ,
Operators::IS_EMPTY,
Operators::NOT_IS_EMPTY,
])
);
}
protected function create_query_bindings($operator, Value $value)
{
$bindings = new ACP\Search\Query\Bindings\QueryArguments();
$compare = '=';
$customer_id = $value->get_value();
switch ($operator) {
case Operators::IS_EMPTY:
$customer_id = 0;
break;
case Operators::NOT_IS_EMPTY:
$compare = '!=';
$customer_id = 0;
}
$bindings->query_arguments([
'field_query' => [
[
'field' => 'customer_id',
'value' => $customer_id,
'compare' => $compare,
],
],
]);
return $bindings;
}
public function get_values($search, $paged)
{
$entities = new ACP\Helper\Select\Entities\User(compact('search', 'paged'));
return new AC\Helper\Select\Options\Paginated(
$entities,
new ACP\Helper\Select\Group\UserRole(
new ACP\Helper\Select\Formatter\UserName($entities)
)
);
}
}