PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Services / Filter / LabelFilter.php

LabelFilter.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Services/Filter/LabelFilter.php

94 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Services\Filter;
4
5 use FluentCart\App\Models\Label;
6 use FluentCart\App\Models\Order;
7 use FluentCart\Framework\Database\Orm\Builder;
8 use FluentCart\Framework\Support\Arr;
9
10 class LabelFilter extends BaseFilter
11 {
12
13 public function applySimpleFilter(?string $search = null): void
14 {
15 $this->query = $this->query->when($search ?? $this->search, function ($query, $search) {
16 return $query->where('value', 'LIKE', "%{$search}%");
17 });
18 }
19
20 public function tabsMap(): array
21 {
22 return [];
23 }
24
25 public function getModel(): string
26 {
27 return Label::class;
28 }
29
30 public static function getFilterName(): string
31 {
32 return 'label';
33 }
34
35 /**
36 * Intentionally empty. This filter cannot receive a request `with` today:
37 * its only caller is AdvanceFilterController::getFilterOption(), which
38 * hand-builds a five-key argument array (remote_data_key, search,
39 * include_ids, limit, parent_id) and never forwards the raw request.
40 *
41 * That is the reason the map is empty, NOT an oversight — if this filter is
42 * ever refactored to take `$request->all()`, an empty map is what keeps it
43 * closed, and any relation it then needs must be added here deliberately as
44 * a context key mapped to a callable.
45 *
46 * @return array<string, callable>
47 */
48 protected function allowedWiths(): array
49 {
50 return [];
51 }
52
53
54 public function applyActiveViewFilter(?string $activeView = null): void
55 {
56
57 }
58
59 public static function getSelectFilterOptions(array $args): array
60 {
61 return static::make($args)->get()->pluck('value', 'id')->toArray();
62 }
63
64 public static function advanceFilterOptions()
65 {
66 return null;
67 }
68
69 public static function advanceFilterOptionsForOther($otherFilters = []): array
70 {
71 return array_merge(
72 $otherFilters,
73 [
74 'labels' => [
75 'label' => __('Labels', 'fluent-cart'),
76 'value' => 'labels',
77 'children' => [
78 [
79 'label' => __('Label Name', 'fluent-cart'),
80 'value' => 'customer_email',
81 'type' => 'selections',
82 'filter_type' => 'relation',
83 'column' => 'label_id',
84 'relation' => 'labels',
85 'remote' => true,
86 'remote_data_key' => 'labels',
87 'is_multiple' => true
88 ]
89 ]
90 ]
91 ]
92 );
93 }
94 }