Add About Section to HomePageSettings and update HomePageController to include brand data. Modify HomeSettings to store new about section fields and update the homepage view to display these settings.
This commit is contained in:
@@ -7,6 +7,7 @@ use Filament\Forms\Components\Grid;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\SettingsPage;
|
||||
@@ -48,6 +49,78 @@ class HomePageSettings extends SettingsPage
|
||||
])->columns(2),
|
||||
]),
|
||||
|
||||
Section::make('About Section')
|
||||
->description('Manage the about section content on the homepage.')
|
||||
->icon('heroicon-o-building-office-2')
|
||||
->schema([
|
||||
TextInput::make('about_subtitle')
|
||||
->label('About Subtitle')
|
||||
->maxLength(100),
|
||||
TextInput::make('about_header')
|
||||
->label('About Header')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Textarea::make('about_paragraph')
|
||||
->label('About Paragraph')
|
||||
->rows(5)
|
||||
->maxLength(65535),
|
||||
Grid::make()->schema([
|
||||
TextInput::make('about_projects_text')
|
||||
->label('Projects Text')
|
||||
->maxLength(100),
|
||||
|
||||
TextInput::make('about_projects_number')
|
||||
->label('Projects Number')
|
||||
->numeric(),
|
||||
|
||||
])->columns(2),
|
||||
Grid::make()->schema([
|
||||
TextInput::make('about_members_text')
|
||||
->label('Members Text')
|
||||
->maxLength(100),
|
||||
|
||||
TextInput::make('about_members_number')
|
||||
->label('Members Number')
|
||||
->numeric(),
|
||||
|
||||
])->columns(2),
|
||||
Grid::make()->schema([
|
||||
|
||||
TextInput::make('about_reviews_text')
|
||||
->label('Reviews Text')
|
||||
->maxLength(100),
|
||||
|
||||
TextInput::make('about_reviews_number')
|
||||
->label('Reviews Number')
|
||||
->numeric(),
|
||||
|
||||
])->columns(2),
|
||||
Grid::make()->schema([
|
||||
TextInput::make('about_button_text')
|
||||
->label('About Button Text')
|
||||
->maxLength(50),
|
||||
TextInput::make('about_button_url')
|
||||
->label('About Button URL')
|
||||
->maxLength(255)
|
||||
->url(),
|
||||
])->columns(2),
|
||||
|
||||
Grid::make()->schema([
|
||||
FileUpload::make('about_image_one')
|
||||
->label('About Image One (245x410)')
|
||||
->image()
|
||||
->maxSize(2048)
|
||||
->disk('public')
|
||||
->directory('about-images'),
|
||||
FileUpload::make('about_image_two')
|
||||
->label('About Image Two (375x391)')
|
||||
->image()
|
||||
->maxSize(2048)
|
||||
->disk('public')
|
||||
->directory('about-images'),
|
||||
])->columns(2),
|
||||
]),
|
||||
|
||||
Section::make('Background Video')
|
||||
->description('Upload or link the background video for the hero section.')
|
||||
->icon('heroicon-o-camera')
|
||||
|
||||
@@ -2,12 +2,16 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Brand;
|
||||
use App\Settings\HomeSettings;
|
||||
|
||||
class HomePageController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('web.pages.home.index');
|
||||
$brands = Brand::query()->get(['id', 'image']);
|
||||
$homeSettings = app(HomeSettings::class);
|
||||
|
||||
return view('web.pages.home.index', compact('homeSettings', 'brands'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,5 @@ class AppServiceProvider extends ServiceProvider
|
||||
$view->with('settings', app(SiteSettings::class));
|
||||
$view->with('socialMedia', app(SiteSocialSettings::class));
|
||||
});
|
||||
|
||||
ViewFacade::composer('web.pages.home.index', function (View $view) {
|
||||
$brands = Brand::query()->get(['id', 'image']);
|
||||
|
||||
$view->with('homepage', app(HomeSettings::class));
|
||||
$view->with('brands', $brands);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,32 @@ class HomeSettings extends Settings
|
||||
|
||||
public string $hero_link_button_text;
|
||||
|
||||
public string $about_subtitle;
|
||||
|
||||
public string $about_header;
|
||||
|
||||
public string $about_paragraph;
|
||||
|
||||
public int $about_projects_number;
|
||||
|
||||
public string $about_projects_text;
|
||||
|
||||
public int $about_members_number;
|
||||
|
||||
public string $about_members_text;
|
||||
|
||||
public int $about_reviews_number;
|
||||
|
||||
public string $about_reviews_text;
|
||||
|
||||
public string $about_button_text;
|
||||
|
||||
public string $about_button_url;
|
||||
|
||||
public string $about_image_one;
|
||||
|
||||
public string $about_image_two;
|
||||
|
||||
public static function group(): string
|
||||
{
|
||||
return 'cms_homepage';
|
||||
|
||||
Reference in New Issue
Block a user