Integrate dynamic settings into About page: update content sections to utilize AboutSettings for titles, subtitles, paragraphs, and media sources, enhancing content management and user experience.
This commit is contained in:
289
app/Filament/Pages/AboutPageSettings.php
Normal file
289
app/Filament/Pages/AboutPageSettings.php
Normal file
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Settings\AboutSettings;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\SettingsPage;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class AboutPageSettings extends SettingsPage
|
||||
{
|
||||
protected static ?string $navigationGroup = 'CMS';
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-information-circle';
|
||||
|
||||
protected static string $settings = AboutSettings::class;
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('Our Story Section')
|
||||
->description("Manage the 'Our Story' content on the About Us page.")
|
||||
->icon('heroicon-o-book-open')
|
||||
->schema([
|
||||
TextInput::make('our_story_title')
|
||||
->label('Title')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
Textarea::make('our_story_subtitle')
|
||||
->label('Subtitle')
|
||||
->rows(2)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
Textarea::make('our_story_paragraph_one')
|
||||
->label('Paragraph One')
|
||||
->rows(4)
|
||||
->maxLength(65535)
|
||||
->required(),
|
||||
Textarea::make('our_story_paragraph_two')
|
||||
->label('Paragraph Two')
|
||||
->rows(4)
|
||||
->maxLength(65535)
|
||||
->required(),
|
||||
Textarea::make('our_story_paragraph_three')
|
||||
->label('Paragraph Three')
|
||||
->rows(4)
|
||||
->maxLength(65535)
|
||||
->required(),
|
||||
Grid::make(2)->schema([
|
||||
TextInput::make('our_story_button_text')
|
||||
->label('Button Text')
|
||||
->maxLength(50)
|
||||
->required(),
|
||||
TextInput::make('our_story_button_url')
|
||||
->label('Button URL')
|
||||
->url()
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
]),
|
||||
FileUpload::make('our_story_video_poster')
|
||||
->label('Video Poster Image')
|
||||
->image()
|
||||
->maxSize(2048)
|
||||
->disk('public')
|
||||
->directory('about-us')
|
||||
->required(),
|
||||
TextInput::make('our_story_video_source')
|
||||
->label('Video Source URL')
|
||||
->url()
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
]),
|
||||
|
||||
Section::make('Our Journey Section')
|
||||
->description("Manage the 'Our Journey' milestones on the About Us page.")
|
||||
->icon('heroicon-o-map')
|
||||
->schema([
|
||||
TextInput::make('our_journey_title')
|
||||
->label('Title')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
Textarea::make('our_journey_subtitle')
|
||||
->label('Subtitle')
|
||||
->rows(2)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
Repeater::make('our_journey_milestones')
|
||||
->label('Milestones')
|
||||
->schema([
|
||||
TextInput::make('year')
|
||||
->label('Year')
|
||||
->numeric()
|
||||
->required(),
|
||||
TextInput::make('title')
|
||||
->label('Milestone Title')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
Textarea::make('description')
|
||||
->label('Description')
|
||||
->rows(3)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
FileUpload::make('image')
|
||||
->label('Image')
|
||||
->image()
|
||||
->maxSize(2048)
|
||||
->disk('public')
|
||||
->directory('about-us-milestones')
|
||||
->required(),
|
||||
])
|
||||
->minItems(1)
|
||||
->columns(1)
|
||||
->reorderable()
|
||||
->collapsible(),
|
||||
]),
|
||||
|
||||
Section::make('Company Structure Section')
|
||||
->description("Manage the 'Company Structure' details on the About Us page.")
|
||||
->icon('heroicon-o-user-group')
|
||||
->schema([
|
||||
TextInput::make('company_structure_title')
|
||||
->label('Title')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
Textarea::make('company_structure_subtitle')
|
||||
->label('Subtitle')
|
||||
->rows(2)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
TextInput::make('company_structure_director_name')
|
||||
->label('Director Name')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
TextInput::make('company_structure_advisor_name')
|
||||
->label('Technical Advisor Name')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
Repeater::make('company_structure_departments')
|
||||
->label('Departments')
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Department Name')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
TextInput::make('person')
|
||||
->label('Contact Person')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
])
|
||||
->minItems(1)
|
||||
->columns(2)
|
||||
->reorderable()
|
||||
->collapsible(),
|
||||
]),
|
||||
|
||||
Section::make('Our Management Section')
|
||||
->description("Manage the 'Our Management' team details on the About Us page.")
|
||||
->icon('heroicon-o-briefcase')
|
||||
->schema([
|
||||
TextInput::make('our_management_title')
|
||||
->label('Title')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
Textarea::make('our_management_subtitle')
|
||||
->label('Subtitle')
|
||||
->rows(2)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
Repeater::make('our_management_team')
|
||||
->label('Team Members')
|
||||
->schema([
|
||||
FileUpload::make('image')
|
||||
->label('Image')
|
||||
->image()
|
||||
->maxSize(2048)
|
||||
->disk('public')
|
||||
->directory('about-us-team')
|
||||
->required(),
|
||||
TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
TextInput::make('title')
|
||||
->label('Title/Position')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
Textarea::make('description')
|
||||
->label('Description')
|
||||
->rows(3)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
])
|
||||
->minItems(1)
|
||||
->columns(1)
|
||||
->reorderable()
|
||||
->collapsible(),
|
||||
]),
|
||||
|
||||
Section::make('Our Facilities Section')
|
||||
->description("Manage the 'Our Facilities' details on the About Us page.")
|
||||
->icon('heroicon-o-building-library')
|
||||
->schema([
|
||||
TextInput::make('our_facilities_title')
|
||||
->label('Title')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
Textarea::make('our_facilities_subtitle')
|
||||
->label('Subtitle')
|
||||
->rows(2)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
Repeater::make('our_facilities_locations')
|
||||
->label('Locations')
|
||||
->schema([
|
||||
FileUpload::make('image')
|
||||
->label('Image')
|
||||
->image()
|
||||
->maxSize(2048)
|
||||
->disk('public')
|
||||
->directory('about-us-facilities')
|
||||
->required(),
|
||||
TextInput::make('name')
|
||||
->label('Location Name')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
TextInput::make('location')
|
||||
->label('Address/Location')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Textarea::make('description')
|
||||
->label('Description')
|
||||
->rows(3)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
Repeater::make('tags')
|
||||
->label('Tags')
|
||||
->simple(TextInput::make('value')
|
||||
->label('Tag')
|
||||
->required()
|
||||
->maxLength(50))
|
||||
->itemLabel(fn (array $state): ?string => $state['value'] ?? null)
|
||||
->minItems(1)
|
||||
->columns(1)
|
||||
->reorderable()
|
||||
->collapsible()
|
||||
->defaultItems(1),
|
||||
])
|
||||
->minItems(1)
|
||||
->columns(1)
|
||||
->reorderable()
|
||||
->collapsible(),
|
||||
]),
|
||||
])
|
||||
->columns(1)
|
||||
->statePath('data');
|
||||
}
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return __('CMS');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('About Page Settings');
|
||||
}
|
||||
|
||||
public function getTitle(): string|Htmlable
|
||||
{
|
||||
return 'About Us';
|
||||
}
|
||||
|
||||
public function getHeading(): string|Htmlable
|
||||
{
|
||||
return 'Edit About Us page text and images from here';
|
||||
}
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Manage the content sections of the About Us page.';
|
||||
}
|
||||
}
|
||||
47
app/Settings/AboutSettings.php
Normal file
47
app/Settings/AboutSettings.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Settings;
|
||||
|
||||
use Spatie\LaravelSettings\Settings;
|
||||
|
||||
class AboutSettings extends Settings
|
||||
{
|
||||
// Our Story Section
|
||||
public string $our_story_title;
|
||||
public string $our_story_subtitle;
|
||||
public string $our_story_paragraph_one;
|
||||
public string $our_story_paragraph_two;
|
||||
public string $our_story_paragraph_three;
|
||||
public string $our_story_button_text;
|
||||
public string $our_story_button_url;
|
||||
public string $our_story_video_poster;
|
||||
public string $our_story_video_source;
|
||||
|
||||
// Our Journey Section
|
||||
public string $our_journey_title;
|
||||
public string $our_journey_subtitle;
|
||||
public array $our_journey_milestones; // [{year: 2010, title: "Start Company", description: "...", image: "..."}]
|
||||
|
||||
// Company Structure Section
|
||||
public string $company_structure_title;
|
||||
public string $company_structure_subtitle;
|
||||
public string $company_structure_director_name;
|
||||
public string $company_structure_advisor_name;
|
||||
public array $company_structure_departments; // [{name: "HSE", person: "Michael Brown"}]
|
||||
|
||||
// Our Management Section
|
||||
public string $our_management_title;
|
||||
public string $our_management_subtitle;
|
||||
public array $our_management_team; // [{name: "John Smith", title: "CEO", description: "...", image: "..."}]
|
||||
|
||||
// Our Facilities Section
|
||||
public string $our_facilities_title;
|
||||
public string $our_facilities_subtitle;
|
||||
public array $our_facilities_locations; // [{name: "Headquarters", location: "...", description: "...", image: "...", tags: ["R&D Labs"]}]
|
||||
|
||||
|
||||
public static function group(): string
|
||||
{
|
||||
return 'cms_aboutpage';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user