5
5
use App \Filament \Clusters \Settings ;
6
6
use App \Settings \FooterSettings ;
7
7
use Filament \Forms ;
8
+ use Filament \Forms \Get ;
9
+ use Filament \Forms \Set ;
8
10
use Filament \Forms \Form ;
9
11
use Filament \Pages \SettingsPage ;
12
+ use Filament \Forms \Components \Select ;
13
+ use Filament \Forms \Components \Toggle ;
14
+ use Filament \Forms \Components \Section ;
15
+ use Filament \Forms \Components \Repeater ;
16
+ use Filament \Forms \Components \TextInput ;
17
+ use Mvenghaus \FilamentPluginTranslatableInline \Forms \Components \TranslatableContainer ;
10
18
11
19
class ManageFooter extends SettingsPage
12
20
{
@@ -20,7 +28,164 @@ public function form(Form $form): Form
20
28
{
21
29
return $ form
22
30
->schema ([
23
- // ...
31
+ Section::make ('Footer Text ' )
32
+ ->description ('Footer Text & Copy Right ' )
33
+ ->schema ([
34
+ TranslatableContainer::make (
35
+ Forms \Components \TextInput::make ('footer_text ' )
36
+ ->required (),
37
+ )
38
+ ->columnSpanFull ()
39
+ ->requiredLocales (['en ' , 'fr ' , 'es ' ]),
40
+ TranslatableContainer::make (
41
+ Forms \Components \TextInput::make ('copy_right ' )
42
+ ->required (),
43
+ )
44
+ ->columnSpanFull ()
45
+ ->requiredLocales (['en ' , 'fr ' , 'es ' ]),
46
+ ]),
47
+
48
+ Section::make ('Newsletter ' )
49
+ ->description ('Newsletter Section ' )
50
+ ->schema ([
51
+ TranslatableContainer::make (
52
+ Forms \Components \TextInput::make ('newsletter_name ' )
53
+ ->required (),
54
+ )
55
+ ->columnSpanFull ()
56
+ ->requiredLocales (['en ' , 'fr ' , 'es ' ]),
57
+ Forms \Components \TextInput::make ('newsletter_email ' )
58
+ ->columnSpanFull ()
59
+ ->required (),
60
+ TranslatableContainer::make (
61
+ Forms \Components \TextInput::make ('newsletter_label ' )
62
+ ->required (),
63
+ )
64
+ ->columnSpanFull ()
65
+ ->requiredLocales (['en ' , 'fr ' , 'es ' ]),
66
+ TranslatableContainer::make (
67
+ Forms \Components \KeyValue::make ('newsletter ' )
68
+ ->columnSpanFull ()
69
+ ->required ()
70
+ ->editableKeys (false )
71
+ ->addable (false )
72
+ ->deletable (false )
73
+ )
74
+ ->columnSpanFull ()
75
+ ->requiredLocales (['en ' , 'fr ' , 'es ' ]),
76
+ ]),
77
+
78
+ Section::make ('Footer Links ' )
79
+ ->description ('Footer Links ' )
80
+ ->schema ([
81
+ TranslatableContainer::make (
82
+ Forms \Components \TextInput::make ('link_name ' )
83
+ ->required (),
84
+ )
85
+ ->columnSpanFull ()
86
+ ->requiredLocales (['en ' , 'fr ' , 'es ' ]),
87
+ TranslatableContainer::make (
88
+ Repeater::make ('links ' )
89
+ ->schema ([
90
+ TextInput::make ('title ' )->required (),
91
+ Select::make ('type ' )
92
+ ->options ([
93
+ 'text ' => 'Text ' ,
94
+ 'link ' => 'Link ' ,
95
+ 'category ' => 'Category ' ,
96
+ 'home ' => 'Home ' ,
97
+ 'post ' => 'Post ' ,
98
+ 'login ' => 'Login ' ,
99
+ 'register ' => 'Register ' ,
100
+ 'terms ' => 'Terms ' ,
101
+ 'privacy ' => 'Privacy ' ,
102
+ 'about ' => 'About ' ,
103
+ 'contact ' => 'Contact ' ,
104
+ ])
105
+ ->afterStateUpdated (function (Set $ set , $ state ) {
106
+ if ($ state === 'login ' ) {
107
+ $ set ('url ' , '/login ' );
108
+ } elseif ($ state === 'register ' ) {
109
+ $ set ('url ' , '/signup ' );
110
+ } elseif ($ state === 'terms ' ) {
111
+ $ set ('url ' , '/terms ' );
112
+ } elseif ($ state === 'privacy ' ) {
113
+ $ set ('url ' , '/privacy ' );
114
+ } elseif ($ state === 'about ' ) {
115
+ $ set ('url ' , '/aboutus ' );
116
+ } elseif ($ state === 'contact ' ) {
117
+ $ set ('url ' , '/contact ' );
118
+ } elseif ($ state === 'category ' ) {
119
+ $ set ('url ' , '/category ' );
120
+ } elseif ($ state === 'post ' ) {
121
+ $ set ('url ' , '/blogs ' );
122
+ } elseif ($ state === 'home ' ) {
123
+ $ set ('url ' , '/ ' );
124
+ }
125
+ })
126
+ ->live ()
127
+ ->required (),
128
+ Select::make ('category ' )
129
+ ->options (fn () => \App \Models \Category::pluck ('name ' , 'slug ' )->toArray ())
130
+ ->visible (fn (Get $ get ): bool => $ get ('type ' ) == 'category ' )
131
+ ->live ()
132
+ ->afterStateUpdated (function (Set $ set , $ state ) {
133
+ $ set ('url ' , '/category/ ' . $ state );
134
+ })
135
+ ->required (),
136
+ Select::make ('post ' )
137
+ ->options (fn () => \App \Models \Post::pluck ('title ' , 'slug ' )->toArray ())
138
+ ->visible (fn (Get $ get ): bool => $ get ('type ' ) == 'post ' )
139
+ ->live ()
140
+ ->afterStateUpdated (function (Set $ set , $ state ) {
141
+ $ set ('url ' , '/post/ ' . $ state );
142
+ }),
143
+ TextInput::make ('url ' )
144
+ ->visible (fn (Get $ get ): bool => $ get ('type ' ) === 'link ' )
145
+ ->required (),
146
+ Toggle::make ('new_tab ' )->default (true ),
147
+ ])->columnSpanFull (),
148
+ )
149
+ ->columnSpanFull ()
150
+ ->requiredLocales (['en ' , 'fr ' , 'es ' ]),
151
+ ]),
152
+
153
+
154
+ Section::make ('Footer Info ' )
155
+ ->description ('Footer Info ' )
156
+ ->schema ([
157
+ TranslatableContainer::make (
158
+ Forms \Components \TextInput::make ('info_name ' )
159
+ ->required (),
160
+ )
161
+ ->columnSpanFull ()
162
+ ->requiredLocales (['en ' , 'fr ' , 'es ' ]),
163
+ TranslatableContainer::make (
164
+ Forms \Components \TextInput::make ('info_desc ' )
165
+ ->required (),
166
+ )
167
+ ->columnSpanFull ()
168
+ ->requiredLocales (['en ' , 'fr ' , 'es ' ]),
169
+ TranslatableContainer::make (
170
+ Repeater::make ('info ' )
171
+ ->schema ([
172
+ TextInput::make ('title ' )->required (),
173
+ TextInput::make ('description ' )->required (),
174
+ TextInput::make ('icon ' )
175
+ ->placeholder ('Pls use feathericons class ' )
176
+ ->label ('Icon (Feathericons) ' )
177
+ ->required (),
178
+ TextInput::make ('value ' )->required (),
179
+ Toggle::make ('active ' )->default (true ),
180
+ ])->columnSpanFull (),
181
+ )
182
+ ->columnSpanFull ()
183
+ ->requiredLocales (['en ' , 'fr ' , 'es ' ]),
184
+ ]),
185
+
186
+
187
+
188
+
24
189
]);
25
190
}
26
191
}
0 commit comments