-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathGlobalSearchFiltersEnum.php
More file actions
134 lines (128 loc) · 4.18 KB
/
GlobalSearchFiltersEnum.php
File metadata and controls
134 lines (128 loc) · 4.18 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
namespace App\Enums;
use App\Event;
use App\StaticPage;
use App\Podcast;
enum GlobalSearchFiltersEnum: string
{
case ALL = 'All';
case PODCASTS = 'Podcasts';
case HACKATHONS = 'Hackathons';
case ONLINE_COURSES = 'Online Courses';
case TRAINING = 'Training';
case CHALLENGES = 'Challenges';
case LEARN = 'Learn';
case TEACH = 'Teach';
case PRESENTATIONS_AND_TOOLKITS = 'Presentations and Toolkits';
case ACTIVITIES = 'Activities';
case BLOGS = 'Blogs';
case OTHERS = 'Others';
/**
* Get additional information for each filter.
*/
public function meta(): array
{
return match ($this) {
self::ALL => [
'type_search' => 'all',
'model' => null,
'search_fields' => [],
],
self::PODCASTS => [
'type_search' => 'model',
'model' => Podcast::class,
'search_fields' => ['title'],
'map_fields' => [
'name' => '{title}',
'category' => 'Podcast',
'description' => '{description}',
'thumbnail' => '{image}',
'path' => '{url}',
'link_type' => 'internal',
'language' => 'en',
]
],
self::HACKATHONS,
self::ONLINE_COURSES,
self::TRAINING,
self::CHALLENGES,
self::PRESENTATIONS_AND_TOOLKITS,
self::OTHERS => [
'type_search' => 'model',
'model' => StaticPage::class,
'search_fields' => [
'description',
'keywords'
],
'map_fields' => [
'name' => '{name}',
'category' => '{category}',
'description' => '{description}',
'thumbnail' => '{thumbnail}',
'path' => '{path}',
'link_type' => '{link_type}',
'language' => '{language}',
]
],
self::LEARN => [
'type_search' => 'function',
'function' => 'searchResources',
'params' => ['section' => 'learn'],
'map_fields' => [
'name' => '{name}',
'category' => 'Learn',
'description' => '',
'thumbnail' => '/img/event_default_picture.png',
'path' => '#',
'link_type' => 'internal',
'language' => 'en',
]
],
self::TEACH => [
'type_search' => 'function',
'function' => 'searchResources',
'params' => ['section' => 'teach'],
'map_fields' => [
'name' => '{name}',
'category' => 'Teach',
'description' => '',
'thumbnail' => '/img/event_default_picture.png',
'path' => '#',
'link_type' => 'internal',
'language' => 'en',
]
],
self::BLOGS => [
'type_search' => 'blog'
],
self::ACTIVITIES => [
'type_search' => 'model',
'model' => Event::class,
'search_fields' => ['title'],
'map_fields' => [
'name' => '{title}',
'category' => 'Activities',
'description' => '{description}',
'thumbnail' => '{picture}',
'path' => '{url}',
'link_type' => 'internal',
'language' => 'en',
]
],
};
}
/**
* Get a list of all enum values.
*/
public static function values(): array
{
return array_column(self::cases(), 'value');
}
/**
* Get a list of all filter keys.
*/
public static function keys(): array
{
return array_map(fn ($case) => $case->name, self::cases());
}
}