Integrate dynamic solution settings into homepage: replace static service titles and button with values from SolutionSettings, and implement a loop to display service items dynamically.
This commit is contained in:
106
app/Filament/Pages/ManageSolutions.php
Normal file
106
app/Filament/Pages/ManageSolutions.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Settings\SolutionSettings;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\SettingsPage;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ManageSolutions extends SettingsPage
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-wrench-screwdriver';
|
||||
|
||||
protected static string $settings = SolutionSettings::class;
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('Solutions Section')
|
||||
->description('Manage the content for the solutions section on the homepage.')
|
||||
->icon('heroicon-o-puzzle-piece')
|
||||
->schema([
|
||||
TextInput::make('solutions_subtitle')
|
||||
->label('Subtitle')
|
||||
->maxLength(100),
|
||||
TextInput::make('solutions_header')
|
||||
->label('Header')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Grid::make()->schema([
|
||||
TextInput::make('solutions_button_text')
|
||||
->label('Button Text')
|
||||
->maxLength(50),
|
||||
TextInput::make('solutions_button_url')
|
||||
->label('Button URL')
|
||||
->maxLength(255)
|
||||
->url(),
|
||||
])->columns(2),
|
||||
]),
|
||||
Section::make('Solution Items')
|
||||
->description('Manage individual solution items.')
|
||||
->icon('heroicon-o-cube')
|
||||
->schema([
|
||||
Repeater::make('solution_items')
|
||||
->label('Solution Items')
|
||||
->schema([
|
||||
TextInput::make('icon_class')
|
||||
->label('Icon Class')
|
||||
->helperText('e.g., flaticon-it-department. Refer to Flaticon for available icons.')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
TextInput::make('title')
|
||||
->label('Title')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
TextInput::make('link')
|
||||
->label('Link')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->url(),
|
||||
])
|
||||
->columns(3)
|
||||
->minItems(1)
|
||||
->maxItems(6)
|
||||
->defaultItems(3)
|
||||
->grid(2)
|
||||
->reorderable()
|
||||
->collapsible(),
|
||||
]),
|
||||
])
|
||||
->columns(1)
|
||||
->statePath('data');
|
||||
}
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return __('CMS');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('Solutions');
|
||||
}
|
||||
|
||||
public function getTitle(): string|Htmlable
|
||||
{
|
||||
return 'Solutions';
|
||||
}
|
||||
|
||||
public function getHeading(): string|Htmlable
|
||||
{
|
||||
return 'Edit solutions text, icons, and links from here';
|
||||
}
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Manage the solutions section content, including individual solution items.';
|
||||
}
|
||||
}
|
||||
23
app/Settings/SolutionSettings.php
Normal file
23
app/Settings/SolutionSettings.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Settings;
|
||||
|
||||
use Spatie\LaravelSettings\Settings;
|
||||
|
||||
class SolutionSettings extends Settings
|
||||
{
|
||||
public string $solutions_subtitle;
|
||||
|
||||
public string $solutions_header;
|
||||
|
||||
public string $solutions_button_text;
|
||||
|
||||
public string $solutions_button_url;
|
||||
|
||||
public array $solution_items;
|
||||
|
||||
public static function group(): string
|
||||
{
|
||||
return 'cms_solutions';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
|
||||
return new class extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->migrator->add('cms_solutions.solutions_subtitle', 'Our Services');
|
||||
$this->migrator->add('cms_solutions.solutions_header', 'Provide Quality Services');
|
||||
$this->migrator->add('cms_solutions.solutions_button_text', 'more Services');
|
||||
$this->migrator->add('cms_solutions.solutions_button_url', 'services.html');
|
||||
$this->migrator->add('cms_solutions.solution_items', [
|
||||
['icon_class' => 'flaticon-it-department', 'title' => 'Flooring Installation', 'link' => '#'],
|
||||
['icon_class' => 'flaticon-project', 'title' => 'Building Architecture', 'link' => '#'],
|
||||
['icon_class' => 'flaticon-design-thinking', 'title' => 'Interior Design', 'link' => '#'],
|
||||
['icon_class' => 'flaticon-data', 'title' => 'House Renovation', 'link' => '#'],
|
||||
]);
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
@extends('web.layouts.app')
|
||||
|
||||
@inject('solutionSettings', 'App\Settings\SolutionSettings')
|
||||
|
||||
@section('content')
|
||||
<!-- Banner Area Start -->
|
||||
<div class="banner__four">
|
||||
@@ -126,10 +128,10 @@
|
||||
<div class="row">
|
||||
<div class="col-xl-5 col-lg-6 lg-mb-25">
|
||||
<div class="services__four-title section-padding pb-0">
|
||||
<span class="subtitle wow fadeInLeft" data-wow-delay=".4s">Our Services</span>
|
||||
<h2 class="title_split_anim">Provide Quality Services</h2>
|
||||
<span class="subtitle wow fadeInLeft" data-wow-delay=".4s">{{ $solutionSettings->solutions_subtitle }}</span>
|
||||
<h2 class="title_split_anim">{{ $solutionSettings->solutions_header }}</h2>
|
||||
<div class="item_bounce">
|
||||
<a class="build_button mt-40" href="services.html">more Services<i class="flaticon-right-up"></i></a>
|
||||
<a class="build_button mt-40" href="{{ $solutionSettings->solutions_button_url }}">{{ $solutionSettings->solutions_button_text }}<i class="flaticon-right-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -143,34 +145,15 @@
|
||||
<div class="col-xl-12">
|
||||
<div class="swiper services_four_slide data_cursor" data-cursor-text="Drag">
|
||||
<div class="swiper-wrapper">
|
||||
@foreach($solutionSettings->solution_items as $item)
|
||||
<div class="swiper-slide">
|
||||
<div class="services__one-item">
|
||||
<i class="flaticon-it-department"></i>
|
||||
<h4><a href="#">Flooring Installation</a></h4>
|
||||
<a class="more_btn" href="#">Read More<i class="flaticon-right-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="swiper-slide">
|
||||
<div class="services__one-item">
|
||||
<i class="flaticon-project"></i>
|
||||
<h4><a href="#">Building Architecture</a></h4>
|
||||
<a class="more_btn" href="#">Read More<i class="flaticon-right-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="swiper-slide">
|
||||
<div class="services__one-item">
|
||||
<i class="flaticon-design-thinking"></i>
|
||||
<h4><a href="#">Interior Design</a></h4>
|
||||
<a class="more_btn" href="#">Read More<i class="flaticon-right-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="swiper-slide">
|
||||
<div class="services__one-item">
|
||||
<i class="flaticon-data"></i>
|
||||
<h4><a href="#">House Renovation</a></h4>
|
||||
<a class="more_btn" href="#">Read More<i class="flaticon-right-up"></i></a>
|
||||
<i class="{{ $item['icon_class'] }}"></i>
|
||||
<h4><a href="{{ $item['link'] }}">{{ $item['title'] }}</a></h4>
|
||||
<a class="more_btn" href="{{ $item['link'] }}">Read More<i class="flaticon-right-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user