Skip to content

Commit d5afa6b

Browse files
Add translatable fields and update settings pages for SEO, Hero, Privacy, and Social configurations
1 parent 5ae0e48 commit d5afa6b

File tree

13 files changed

+863
-25
lines changed

13 files changed

+863
-25
lines changed

app/Filament/Clusters/Settings/Pages/ManageAbout.php

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Filament\Forms;
88
use Filament\Forms\Form;
99
use Filament\Pages\SettingsPage;
10+
use Mvenghaus\FilamentPluginTranslatableInline\Forms\Components\TranslatableContainer;
1011

1112
class ManageAbout extends SettingsPage
1213
{
@@ -20,7 +21,64 @@ public function form(Form $form): Form
2021
{
2122
return $form
2223
->schema([
23-
// ...
24+
25+
Forms\Components\Section::make('The About Page')->schema([
26+
TranslatableContainer::make(
27+
Forms\Components\TextInput::make('title')
28+
->required(),
29+
)
30+
->columnSpanFull()
31+
->requiredLocales(['en', 'fr', 'es']),
32+
TranslatableContainer::make(
33+
Forms\Components\TextInput::make('desc')
34+
->required(),
35+
)
36+
->columnSpanFull()
37+
->requiredLocales(['en', 'fr', 'es']),
38+
TranslatableContainer::make(
39+
Forms\Components\MarkdownEditor::make('content')
40+
->disableToolbarButtons(['table'])
41+
->columnSpanFull()
42+
->required(),
43+
)
44+
->columnSpanFull()
45+
->requiredLocales(['en', 'fr', 'es']),
46+
])->columns(2),
47+
48+
Forms\Components\Section::make('Visitors')->schema([
49+
Forms\Components\TextInput::make('visitors_number')
50+
->label('Number of visitors')
51+
->required(),
52+
TranslatableContainer::make(
53+
Forms\Components\TextInput::make('visitors_text')
54+
->label('Visitors text')
55+
->required(),
56+
)
57+
->columnSpanFull()
58+
->requiredLocales(['en', 'fr', 'es']),
59+
Forms\Components\TextInput::make('visitors_icon')
60+
->placeholder('Pls use feathericons class')
61+
->label('Visitors icon (feathericons)')
62+
->required(),
63+
])->columns(2),
64+
65+
Forms\Components\Section::make('Tours')->schema([
66+
Forms\Components\TextInput::make('tours_number')
67+
->label('Number of tours')
68+
->required(),
69+
TranslatableContainer::make(
70+
Forms\Components\TextInput::make('tours_text')
71+
->label('Tours text')
72+
->required(),
73+
)
74+
->columnSpanFull()
75+
->requiredLocales(['en', 'fr', 'es']),
76+
Forms\Components\TextInput::make('tours_icon')
77+
->placeholder('Pls use feathericons class')
78+
->label('Tours icon (feathericons)')
79+
->required(),
80+
])->columns(2),
81+
2482
]);
2583
}
2684
}

app/Filament/Clusters/Settings/Pages/ManageContact.php

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Filament\Forms;
88
use Filament\Forms\Form;
99
use Filament\Pages\SettingsPage;
10+
use Filament\Forms\Components\Section;
11+
use Filament\Forms\Components\Repeater;
12+
use Mvenghaus\FilamentPluginTranslatableInline\Forms\Components\TranslatableContainer;
1013

1114
class ManageContact extends SettingsPage
1215
{
@@ -20,7 +23,56 @@ public function form(Form $form): Form
2023
{
2124
return $form
2225
->schema([
23-
// ...
26+
Forms\Components\TextInput::make('email')
27+
->columnSpanFull()
28+
->label('Email')
29+
->required(),
30+
TranslatableContainer::make(
31+
Forms\Components\TextInput::make('button_text')
32+
->maxLength(255)
33+
->required()
34+
)
35+
->columnSpanFull()
36+
->requiredLocales(['en', 'fr', 'es']),
37+
TranslatableContainer::make(
38+
Forms\Components\TextInput::make('label')
39+
->maxLength(255)
40+
->required()
41+
)
42+
->columnSpanFull()
43+
->requiredLocales(['en', 'fr', 'es']),
44+
Section::make('Google Map')
45+
->description('You can get the iframe from Google Maps by clicking on the share button and then on the embed map button.')
46+
->schema([
47+
Forms\Components\Textarea::make('google_map_iframe')
48+
->columnSpanFull()
49+
->label('Google Map Iframe')
50+
->required(),
51+
]),
52+
TranslatableContainer::make(
53+
Repeater::make('info')
54+
->schema([
55+
Forms\Components\TextInput::make('name')
56+
->label('Name')
57+
->required(),
58+
Forms\Components\TextInput::make('icon')
59+
->placeholder('Pls use feathericons class')
60+
->label('Icon (feathericons)')
61+
->required(),
62+
Forms\Components\TextInput::make('value')
63+
->label('Value')
64+
->required(),
65+
Forms\Components\TextInput::make('link')
66+
->label('Link')
67+
->required(),
68+
Forms\Components\TextInput::make('description')
69+
->label('Description')
70+
->required(),
71+
]),
72+
)
73+
->columnSpanFull()
74+
->requiredLocales(['en', 'fr', 'es']),
75+
2476
]);
2577
}
2678
}

app/Filament/Clusters/Settings/Pages/ManageFooter.php

Lines changed: 166 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@
55
use App\Filament\Clusters\Settings;
66
use App\Settings\FooterSettings;
77
use Filament\Forms;
8+
use Filament\Forms\Get;
9+
use Filament\Forms\Set;
810
use Filament\Forms\Form;
911
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;
1018

1119
class ManageFooter extends SettingsPage
1220
{
@@ -20,7 +28,164 @@ public function form(Form $form): Form
2028
{
2129
return $form
2230
->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+
24189
]);
25190
}
26191
}

0 commit comments

Comments
 (0)