Add contact settings integration: update contact page to utilize dynamic settings for subtitle, header, paragraph, contact details, and map embed URL, enhancing content management and user experience.

This commit is contained in:
2025-07-29 13:22:44 +05:00
parent 287fbf55f9
commit c37f5fadf1
5 changed files with 143 additions and 7 deletions

View File

@@ -0,0 +1,87 @@
<?php
namespace App\Filament\Pages;
use App\Settings\ContactSettings;
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 ContactPageSettings extends SettingsPage
{
protected static ?string $navigationGroup = 'CMS';
protected static ?string $navigationIcon = 'heroicon-o-phone';
protected static string $settings = ContactSettings::class;
public function form(Form $form): Form
{
return $form
->schema([
Section::make('Contact Section')
->description('Manage the contact page content.')
->schema([
TextInput::make('contact_subtitle')
->label('Subtitle')
->maxLength(100)
->required(),
TextInput::make('contact_header')
->label('Header')
->maxLength(100)
->required(),
Textarea::make('contact_paragraph')
->label('Paragraph')
->rows(3)
->maxLength(65535)
->required(),
TextInput::make('phone_number')
->label('Phone Number')
->tel()
->required(),
TextInput::make('email_address')
->label('Email Address')
->email()
->required(),
TextInput::make('location_address')
->label('Location Address')
->maxLength(255)
->required(),
TextInput::make('map_embed_url')
->label('Google Maps Embed URL')
->url()
->required(),
])
])
->columns(1)
->statePath('data');
}
public static function getNavigationGroup(): ?string
{
return __('CMS');
}
public static function getNavigationLabel(): string
{
return __('Contact Page Settings');
}
public function getTitle(): string|Htmlable
{
return 'Contact Page';
}
public function getHeading(): string|Htmlable
{
return 'Edit contact page text and information from here';
}
public function getSubheading(): string|Htmlable|null
{
return 'Manage the contact form details, contact information, and map embed.';
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Settings;
use Spatie\LaravelSettings\Settings;
class ContactSettings extends Settings
{
public string $contact_subtitle = 'Default Contact Subtitle';
public string $contact_header = 'Default Contact Header';
public string $contact_paragraph = 'This is a default paragraph for the contact page. Please update it from the Filament panel.';
public string $phone_number = '+1234567890';
public string $email_address = 'info@example.com';
public string $location_address = '123 Main St, Anytown, USA';
public string $map_embed_url = '';
public static function group(): string
{
return 'contact';
}
}

View File

@@ -3,6 +3,7 @@
use App\Settings\GeneralSettings;
use App\Settings\HomeSettings;
use App\Settings\SiteSettings;
use Spatie\LaravelData\Data;
return [
@@ -14,6 +15,7 @@ return [
GeneralSettings::class,
SiteSettings::class,
HomeSettings::class,
\App\Settings\ContactSettings::class,
],
/*

View File

@@ -0,0 +1,17 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
return new class extends SettingsMigration
{
public function up(): void
{
$this->migrator->add('contact.contact_subtitle', 'Default Contact Subtitle');
$this->migrator->add('contact.contact_header', 'Default Contact Header');
$this->migrator->add('contact.contact_paragraph', 'This is a default paragraph for the contact page. Please update it from the Filament panel.');
$this->migrator->add('contact.phone_number', '+1234567890');
$this->migrator->add('contact.email_address', 'info@example.com');
$this->migrator->add('contact.location_address', '123 Main St, Anytown, USA');
$this->migrator->add('contact.map_embed_url', '');
}
};

View File

@@ -1,6 +1,9 @@
@extends('web.layouts.app')
@section('content')
@php
$contactSettings = app(\App\Settings\ContactSettings::class);
@endphp
<!-- Breadcrumb Area Start -->
<div class="breadcrumb__area" style="background-image: url('/web/assets/img/page/breadcrumb.jpg');">
<div class="container">
@@ -25,9 +28,9 @@
<div class="col-lg-5 lg-mb-25">
<div class="contact__area-left mr-40 xl-mr-0">
<div class="title">
<span class="subtitle wow fadeInLeft" data-wow-delay=".4s">Contact Us</span>
<h2 class="title_split_anim mb-25">Get In Touch</h2>
<p class="wow fadeInUp" data-wow-delay=".4s">Were here to assist you! Please reach out with any questions, feedback, or project inquiries.</p>
<span class="subtitle wow fadeInLeft" data-wow-delay=".4s">{{ $contactSettings->contact_subtitle }}</span>
<h2 class="title_split_anim mb-25">{{ $contactSettings->contact_header }}</h2>
<p class="wow fadeInUp" data-wow-delay=".4s">{{ $contactSettings->contact_paragraph }}</p>
</div>
<div class="contact__area-left-contact wow fadeInUp" data-wow-delay=".7s">
<div class="contact__area-left-contact-item">
@@ -36,7 +39,7 @@
</div>
<div class="contact__area-left-contact-item-content">
<span>Phone:</span>
<h6><a href="tel:+123 (256) 568 58">+123 (256) 568 58</a></h6>
<h6><a href="tel:{{ $contactSettings->phone_number }}">{{ $contactSettings->phone_number }}</a></h6>
</div>
</div>
<div class="contact__area-left-contact-item">
@@ -45,7 +48,7 @@
</div>
<div class="contact__area-left-contact-item-content">
<span>Email Address:</span>
<h6><a href="mailto:needhelp@gmail.com">needhelp@gmail.com</a></h6>
<h6><a href="mailto:{{ $contactSettings->email_address }}">{{ $contactSettings->email_address }}</a></h6>
</div>
</div>
<div class="contact__area-left-contact-item">
@@ -54,7 +57,7 @@
</div>
<div class="contact__area-left-contact-item-content">
<span>Location:</span>
<h6><a href="https://google.com/maps" target="_blank">2464 Royal Ln. Mesa, New Jersey 45463</a></h6>
<h6><a href="https://google.com/maps" target="_blank">{{ $contactSettings->location_address }}</a></h6>
</div>
</div>
</div>
@@ -104,7 +107,7 @@
<div class="row">
<div class="col-xl-12 wow fadeInUp" data-wow-delay=".4s">
<div class="map-area">
<iframe loading="lazy" src="https://maps.google.com/maps?q=London%20Eye%2C%20London%2C%20United%20Kingdom&amp;t=m&amp;z=10&amp;output=embed&amp;iwloc=near" title="London Eye, London, United Kingdom" aria-label="London Eye, London, United Kingdom"></iframe>
<iframe src="{{ $contactSettings->map_embed_url }}" loading="lazy" referrerpolicy="no-referrer-when-downgrade" title="Ashgabat, Turkmenistan" aria-label="Ashgabat, Turkmenistan"></iframe>
</div>
</div>
</div>