Files
gujurly.com/app/Filament/Pages/AboutPageSettings.php

260 lines
11 KiB
PHP

<?php
namespace App\Filament\Pages;
use App\Models\UserRole;
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(),
FileUpload::make('our_story_video_source')
->label('Video Source File')
->acceptedFileTypes(['video/mp4', 'video/webm', 'video/ogg'])
->maxSize(102400) // 100MB
->disk('public')
->directory('about-us-videos')
->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 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 __('About US');
}
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.';
}
public static function canAccess(): bool
{
return auth()->user()->canManageSettings();
}
public static function canView(): bool
{
return auth()->user()->role === UserRole::ADMIN || auth()->user()->role === UserRole::MANAGER;
}
}