PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.4
1.6.6 1.6.5 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 All 49 releases
fluent-cart / app / Services / Filter / AttrTermFilter.php

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

74 lines 1.8 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\AttributeTerm;
6 use FluentCart\App\Services\Filter\BaseFilter;
7 use FluentCart\App\Services\Filter\Concerns\HasIdTitleSlugSearch;
8
9 class AttrTermFilter extends BaseFilter
10 {
11 use HasIdTitleSlugSearch;
12 public string $defaultSortBy = 'serial';
13 public string $defaultSortType = 'asc';
14
15 protected function parseSortBy(): string
16 {
17 return 'serial';
18 }
19
20 protected function parseSortType(): string
21 {
22 return 'asc';
23 }
24
25 protected ?int $groupId = null;
26
27 public function setGroupId(int $groupId): self
28 {
29 $this->groupId = $groupId;
30 return $this;
31 }
32
33 public function applySelect(): void
34 {
35 $this->query->select(['id', 'title', 'settings', 'serial', 'created_at']);
36 }
37
38 protected function buildCommonQuery()
39 {
40 if ($this->groupId) {
41 $this->query->where('group_id', $this->groupId);
42 }
43
44 parent::buildCommonQuery();
45
46 // Default sort is serial ASC, but two terms can share the same serial
47 // (the swap-on-reorder logic guarantees uniqueness within a group at
48 // the moment of reorder, but bulk imports or partial states can leave
49 // ties). Append id ASC as a deterministic tie-breaker so paginated
50 // listings stay stable across requests.
51 $this->query->orderBy('id', 'ASC');
52 }
53
54 public function tabsMap(): array
55 {
56 return [];
57 }
58
59 public function getModel(): string
60 {
61 return AttributeTerm::class;
62 }
63
64 public static function getFilterName(): string
65 {
66 return 'attr_terms';
67 }
68
69 public function applyActiveViewFilter(?string $activeView = null): void
70 {
71 // Terms have no tab views; this hook is intentionally a no-op.
72 }
73 }
74