Add downloads and FAQs functionality to SolutionResource: implement repeaters for downloads and FAQs in the form, update Solution model to include new fields, and enhance the show view to display downloads and FAQs dynamically, improving content management and user experience.

This commit is contained in:
2025-07-29 14:54:13 +05:00
parent e97a80bfdb
commit 0a3fdf347f
5 changed files with 125 additions and 43 deletions

View File

@@ -49,6 +49,34 @@ class SolutionResource extends Resource
->columnSpanFull()
->createItemButtonLabel('Add Bullet Point')
->defaultItems(1),
Forms\Components\Repeater::make('downloads')
->schema([
Forms\Components\TextInput::make('title')
->label('Download Title')
->required(false),
Forms\Components\FileUpload::make('file')
->label('Download File')
->required(false)
->disk('public')
->directory('solution-downloads'),
])
->columns(1)
->columnSpanFull()
->createItemButtonLabel('Add Download Item')
->defaultItems(1),
Forms\Components\Repeater::make('faqs')
->schema([
Forms\Components\TextInput::make('question')
->label('Question')
->required(),
Forms\Components\RichEditor::make('answer')
->label('Answer')
->required(),
])
->columns(1)
->columnSpanFull()
->createItemButtonLabel('Add FAQ')
->defaultItems(1),
Forms\Components\RichEditor::make('description')
->required()
->columnSpanFull(),

View File

@@ -15,9 +15,13 @@ class Solution extends Model
'slug',
'title_description',
'bullets',
'downloads',
'faqs',
];
protected $casts = [
'bullets' => 'array',
'downloads' => 'array',
'faqs' => 'array',
];
}

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('solutions', function (Blueprint $table) {
$table->json('downloads')->nullable()->after('bullets');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('solutions', function (Blueprint $table) {
$table->dropColumn('downloads');
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('solutions', function (Blueprint $table) {
$table->json('faqs')->nullable()->after('downloads');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('solutions', function (Blueprint $table) {
$table->dropColumn('faqs');
});
}
};

View File

@@ -23,60 +23,54 @@
<div class="container">
<div class="row">
<div class="col-lg-4">
<div class="all__sidebar">
<div class="all__sidebar">
<div class="all__sidebar-item">
<h4>Download</h4>
<h4>Downloads</h4>
<div class="all__sidebar-item-download">
<ul>
<li><a href="#">Company Details<span class="fal fa-arrow-to-bottom"></span></a></li>
<li><a href="#">Our Brochures<span class="fal fa-arrow-to-bottom"></span></a></li>
</ul>
@if ($solution->downloads && count($solution->downloads) > 0)
@foreach ($solution->downloads as $download)
@if (isset($download['title']) && isset($download['file']))
<li><a href="{{ Storage::url($download['file']) }}">{{ $download['title'] }}<span class="fal fa-arrow-to-bottom"></span></a></li>
@endif
@endforeach
@else
<li>No downloads available...</li>
@endif
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-8">
<div class="services__details-area">
<h3 class="mt-25 mb-20">{{ $solution->title }}</h3>
<p class="mb-20">{{ $solution->title_description }}</p>
<p class="mb-25">With years of industry experience, our team handles every aspect of the construction process, your project runs smoothly and efficiently. We prioritize open communication, timely delivery, and quality workmanship to exceed your expectations. Trust us to provide innovative solutions that.</p>
<h4 class="mb-20">Building with Unmatched Excellence</h4>
<p>Transform your existing space with our renovation and remodeling services. Whether you want to update your kitchen, bathroom, or entire home, we bring innovative solutions to enhance your living space. Our team has extensive experience in commercial construction, including office buildings, retail spaces, and industrial facilities. We work closely with you to ensure your project align.</p>
<div class="row mt-40 mb-40">
<div class="col-sm-6 sm-mb-25">
<img class="img_full" src="/web/assets/img/portfolio/portfolio-5.jpg" alt="image">
</div>
<div class="col-sm-6">
<img class="img_full" src="/web/assets/img/portfolio/portfolio-8.jpg" alt="image">
</div>
</div>
<p>We deliver exceptional construction services backed by years of experience. Our skilled team prioritizes quality, transparency, and client satisfaction. We utilize innovative techniques and sustainable practices, ensuring timely project completion. Trust us to bring your to life with unmatched craftsmanship</p>
<ul class="services__details-area-list">
<li><i class="flaticon-check-mark"></i>Our skilled professionals bring years of experience a</span></li>
<li><i class="flaticon-check-mark"></i>We are the leading construction company in the industry.</span></li>
<li><i class="flaticon-check-mark"></i>Our transparent pricing ensures no hidden fees or surprises.</span></li>
<li><i class="flaticon-check-mark"></i>We adhere to strict safety standards on all job sites.</span></li>
</ul>
<h3>Commonly Asked Questions</h3>
{!! $solution->description !!}
@if (count($solution->bullets) > 0)
<h4 class="mb-20 mt-40">Key Aspects of Our Solutions</h4>
<ul class="services__details-area-list">
@foreach ($solution->bullets as $bullet)
@if (isset($bullet['bullet']))
<li><i class="flaticon-check-mark"></i>{{ $bullet['bullet'] }}</li>
@endif
@endforeach
</ul>
@endif
<h3>Frequently Asked Questions</h3>
<div class="mt-30" id="accordionExample">
<div class="faq-item">
<h5 class="icon" data-bs-toggle="collapse" data-bs-target="#collapseOne">1. What services do you offer?</h5>
<div id="collapseOne" class="faq-item-body collapse show" data-bs-parent="#accordionExample">
<p>We offer a range of services including construction management, design-build solutions, renovations, and specialty contracting for both residential and commercial projects</p>
</div>
</div>
<div class="faq-item">
<h5 class="icon collapsed" data-bs-toggle="collapse" data-bs-target="#collapseTwo">2. Do you provide free estimates?</h5>
<div id="collapseTwo" class="faq-item-body collapse" data-bs-parent="#accordionExample">
<p>Yes, we offer free estimates for all potential projects. We assess your requirements and provide a detailed quote without any obligation</p>
</div>
</div>
<div class="faq-item">
<h5 class="icon collapsed" data-bs-toggle="collapse" data-bs-target="#collapseThree">3. Are you licensed and insured?</h5>
<div id="collapseThree" class="faq-item-body collapse" data-bs-parent="#accordionExample">
<p>Yes, we are fully licensed and insured to operate in our service areas. This ensures that your project is protected and complies with all local regulations</p>
</div>
</div>
@if ($solution->faqs && count($solution->faqs) > 0)
@foreach ($solution->faqs as $key => $faq)
<div class="faq-item">
<h5 class="icon {{ $key === 0 ? '' : 'collapsed' }}" data-bs-toggle="collapse" data-bs-target="#collapse{{ $key + 1 }}">{{ $key + 1 }}. {{ $faq['question'] }}</h5>
<div id="collapse{{ $key + 1 }}" class="faq-item-body collapse {{ $key === 0 ? 'show' : '' }}" data-bs-parent="#accordionExample">
<p>{!! $faq['answer'] !!}</p>
</div>
</div>
@endforeach
@else
<p>No FAQs available.</p>
@endif
</div>
</div>
</div>