services done

This commit is contained in:
2025-06-05 15:19:12 +05:45
parent 18e5f8f173
commit 01785b7bb9
21 changed files with 691 additions and 8 deletions

View File

@ -0,0 +1,75 @@
<?php
namespace App\Http\Controllers;
use App\Models\About;
use Illuminate\Http\Request;
class AboutController extends Controller
{
// Show all blocks
public function index()
{
$abouts = About::orderBy('display_order')->get();
return view('abouts.index', compact('abouts'));
}
// Show form to create new block
public function create()
{
return view('abouts.create');
}
// Store new block to DB
public function store(Request $request)
{
$data = $this->validateData($request);
About::create($data);
return redirect()->route('abouts.index')->with('success', 'Block created successfully.');
}
// Show form to edit a block
public function edit($id)
{
$about = About::findOrFail($id);
return view('abouts.edit', compact('about'));
}
// Update existing block
public function update(Request $request, $id)
{
$about = About::findOrFail($id);
$data = $this->validateData($request);
$about->update($data);
return redirect()->route('abouts.index')->with('success', 'Block updated successfully.');
}
// Delete a block
public function destroy($id)
{
$about = About::findOrFail($id);
$about->delete();
return redirect()->route('abouts.index')->with('success', 'Block deleted successfully.');
}
// Validation rules
protected function validateData(Request $request)
{
return $request->validate([
'title' => 'nullable|string|max:255',
'description' => 'nullable|string',
'icon_class' => 'nullable|string|max:255',
'button_text' => 'nullable|string|max:100',
'button_url' => 'nullable|string|max:255',
'image' => 'nullable|image|max:2048', // max 2MB image upload
'display_order' => 'nullable|integer',
'extra_classes' => 'nullable|string|max:255',
]);
}
}

View File

@ -8,6 +8,8 @@ use Illuminate\Http\Request;
use App\Models\Post;
use App\Models\Slider;
use App\Models\Preparation;
use App\Models\Service;
use App\Models\About;
class FrontendController extends Controller
{
@ -15,8 +17,8 @@ class FrontendController extends Controller
{
$data['sliderItems'] = Slider::all();
$data['preparations'] = Preparation::all();
// $data['services'] = Service::all();
// $data['about'] = About::all();
$data['services'] = Service::all();
$data['about'] = About::all();
// $data['contact'] = Contact::first();
// $data['testimonials'] = Testimonial::all();
// $data['partners'] = Partner::all();

View File

@ -0,0 +1,81 @@
<?php
namespace App\Http\Controllers;
use App\Models\Service;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
class ServiceController extends Controller
{
public function index()
{
$services = Service::all();
return view('services.index', compact('services'));
}
public function create()
{
return view('services.create');
}
public function store(Request $request)
{
$validated = $request->validate([
'title' => 'required|string|max:225',
'description' => 'required|string',
'button_url' => 'nullable|url',
'image' => 'nullable|image|mimes:jpeg,png,jpg,webp|max:2048',
]);
if ($request->hasFile('image')) {
$validated['image'] = $request->file('image')->store('services', 'public');
}
Service::create($validated);
return redirect()->route('services.index')->with('success', 'Service created successfully');
}
public function show(Service $service)
{
return view('services.show', compact('service'));
}
public function edit(Service $service)
{
return view('services.edit', compact('service'));
}
public function update(Request $request, Service $service)
{
$validated = $request->validate([
'title' => 'required|string|max:225',
'description' => 'required|string',
'button_url' => 'nullable|string',
'image' => 'nullable|image|mimes:jpeg,png,jpg,webp|max:2048',
]);
if ($request->hasFile('image')) {
// Delete old image
if ($service->image) {
Storage::disk('public')->delete($service->image);
}
$validated['image'] = $request->file('image')->store('services', 'public');
}
$service->update($validated);
return redirect()->route('services.index')->with('success', 'Service updated successfully');
}
public function destroy(Service $service)
{
if ($service->image) {
Storage::disk('public')->delete($service->image);
}
$service->delete();
return redirect()->route('services.index')->with('success', 'Service deleted successfully');
}
}

10
app/Models/Service.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Service extends Model
{
protected $fillable = ['title', 'description', 'image', 'button_url'];
}

22
app/Models/about.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class about extends Model
{
use HasFactory;
protected $fillable = [
'title',
'description',
'icon_class',
'button_text',
'button_url',
'image',
'display_order',
'extra_classes'
];
//
}

View File

@ -0,0 +1,31 @@
<?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::create('services', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('description');
$table->string('image')->nullable();
$table->string('button_url')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('services');
}
};

View File

@ -0,0 +1,35 @@
<?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::create('abouts', function (Blueprint $table) {
$table->id();
$table->string('title')->nullable();
$table->text('description')->nullable();
$table->string('icon_class')->nullable();
$table->string('button_text')->nullable();
$table->string('button_url')->nullable();
$table->string('image')->nullable();
$table->integer('display_order')->nullable();
$table->string('extra_classes')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('abouts');
}
};

View File

@ -0,0 +1,52 @@
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create About Section</h1>
<form action="{{ route('abouts.store') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="form-group mb-3">
<label for="title">Title</label>
<input type="text" name="title" value="{{ old('title') }}" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="description">Description</label>
<textarea name="description" class="form-control" rows="4">{{ old('description') }}</textarea>
</div>
<div class="form-group mb-3">
<label for="icon_class">Icon Class</label>
<input type="text" name="icon_class" value="{{ old('icon_class') }}" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="button_text">Button Text</label>
<input type="text" name="button_text" value="{{ old('button_text') }}" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="button_url">Button URL</label>
<input type="text" name="button_url" value="{{ old('button_url') }}" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="image">Image</label>
<input type="file" name="image" class="form-control" />
</div>
<div class="form-group mb-3">
<label for ="display_order">Display Order</label>
<input type="number" name="display_order" value="{{ old('display_order') }}" class="form-control" />
</div>
<div class="form-group mb-3">
<label for ="extra_classes">Extra Classes</label>
<input type="text" name="extra_classes" value="{{ old('extra_classes') }}" class="form-control" />
</div>
<button class="btn btn-success" type="submit">Save</button>
<a href="{{ route('abouts.index') }}" class="btn btn-secondary">Cancel</a>
</form>
</div>
@endsection

View File

@ -0,0 +1,64 @@
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit About Section</h1>
<form action="{{ route('abouts.update', $about->id) }}" method="POST" enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="form-group mb-3">
<label>Title</label>
<input type="text" name="title" value="{{ old('title', $about->title) }}" class="form-control" />
</div>
<div class="form-group mb-3">
<label>Description</label>
<textarea name="description" class="form-control" rows="4">{{ old('description', $about->description) }}</textarea>
</div>
<div class="form-group mb-3">
<label>Icon Class</label>
<input type="text" name="icon_class" value="{{ old('icon_class', $about->icon_class) }}" class="form-control" />
</div>
<div class="form-group mb-3">
<label>Button Text</label>
<input type="text" name="button_text" value="{{ old('button_text', $about->button_text) }}" class="form-control" />
</div>
<div class="form-group mb-3">
<label>Button URL</label>
<input type="text" name="button_url" value="{{ old('button_url', $about->button_url) }}" class="form-control" />
</div>
<div class="form-group mb-3">
<label>Current Image</label><br/>
@if($about->image)
<img src="{{ asset('storage/' . $about->image) }}" alt="Image" width="120" />
@else
No image uploaded
@endif
</div>
<div class="form-group mb-3">
<label>Change Image</label>
<input type="file" name="image" class="form-control" />
</div>
<div class="form-group mb-3">
<label>Display Order</label>
<input type="number" name="display_order" value="{{ old('display_order', $about->display_order) }}" class="form-control" />
</div>
<div class="form-group mb-3">
<label>Extra Classes</label>
<input type="text" name="extra_classes" value="{{ old('extra_classes', $about->extra_classes) }}" class="form-control" />
</div>
<button class="btn btn-primary" type="submit">Update</button>
<a href="{{ route('abouts.index') }}" class="btn btn-secondary">Cancel</a>
</form>
</div>
@endsection

View File

@ -0,0 +1,55 @@
@extends('layouts.app')
@section('content')
<div class="container">
<h1>About Sections</h1>
<a href="{{ route('abouts.create') }}" class="btn btn-primary mb-3">Create New About</a>
@if(session('success'))
<div class="alert alert-success">{{ session('success') }}</div>
@endif
<table class="table table-bordered">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Icon Class</th>
<th>Button Text</th>
<th>Button URL</th>
<th>Image</th>
<th>Display Order</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($abouts as $about)
<tr>
<td>{{ $about->title }}</td>
<td>{{ Str::limit($about->description, 50) }}</td>
<td>{{ $about->icon_class }}</td>
<td>{{ $about->button_text }}</td>
<td>{{ $about->button_url }}</td>
<td>
@if($about->image)
<img src="{{ asset('storage/' . $about->image) }}" alt="Image" width="80" />
@else
-
@endif
</td>
<td>{{ $about->display_order }}</td>
<td>
<a href="{{ route('abouts.show', $about->id) }}" class="btn btn-sm btn-info">View</a>
<a href="{{ route('abouts.edit', $about->id) }}" class="btn btn-sm btn-warning">Edit</a>
<form action="{{ route('abouts.destroy', $about->id) }}" method="POST" style="display:inline-block;" onsubmit="return confirm('Delete this about?')">
@csrf
@method('DELETE')
<button class="btn btn-sm btn-danger" type="submit">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

View File

@ -0,0 +1,26 @@
@extends('layouts.app')
@section('content')
<div class="container">
<h1>About Details</h1>
<div class="mb-3"><strong>Title:</strong> {{ $about->title }}</div>
<div class="mb-3"><strong>Description:</strong> {!! nl2br(e($about->description)) !!}</div>
<div class="mb-3"><strong>Icon Class:</strong> {{ $about->icon_class }}</div>
<div class="mb-3"><strong>Button Text:</strong> {{ $about->button_text }}</div>
<div class="mb-3"><strong>Button URL:</strong> <a href="{{ $about->button_url }}" target="_blank">{{ $about->button_url }}</a></div>
<div class="mb-3">
<strong>Image:</strong><br />
@if($about->image)
<img src="{{ asset('storage/' . $about->image) }}" alt="Image" style="max-width:300px;" />
@else
No image uploaded
@endif
</div>
<div class="mb-3"><strong>Display Order:</strong> {{ $about->display_order }}</div>
<div class="mb-3"><strong>Extra Classes:</strong> {{ $about->extra_classes }}</div>
<a href="{{ route('abouts.index') }}" class="btn btn-secondary">Back to List</a>
<a href="{{ route('abouts.edit', $about->id) }}" class="btn btn-warning">Edit</a>
</div>
@endsection

View File

@ -9,6 +9,10 @@
<a href="{{ route('posts.index') }}" class="btn btn-secondary">Manage Posts</a>
<a href="{{ route('sliders.index') }}" class="btn btn-secondary">Manage Sliders</a>
<a href="{{ route('preparations.index') }}" class="btn btn-secondary">Manage Preparations</a>
<a href="{{ route('services.index') }}" class="btn btn-secondary">Manage Services</a>
<a href="{{ route('abouts.index') }}" class="btn btn-secondary">Manage Abouts</a>
</div>
</div>
@endsection

View File

@ -4,8 +4,8 @@
@include('frontend.header')
@include('frontend.partials.slider', ['sliderItems' => $sliderItems])
@include('frontend.partials.preparation', ['preparations' => $preparations])
{{-- @include('frontend.partials.service', ['services' => $services]) --}}
{{-- @include('frontend.partials.about', ['about' => $about]) --}}
@include('frontend.partials.service', ['services' => $services])
@include('frontend.partials.about', ['about' => $about])
{{-- @include('frontend.partials.contact', ['contact' => $contact]) --}}
{{-- @include('frontend.partials.testimonial', ['testimonials' => $testimonials]) --}}
{{-- @include('frontend.partials.partners', ['partners' => $partners]) --}}

View File

@ -49,7 +49,7 @@
</div>
<div class="col-lg-4 order-lg-0 res-991-display-none res-991-mt-15">
</div> --}}
@foreach($popups as $popup)
@foreach($abouts as $about)
<div class="col-lg-4 order-lg-3 res-991-mt-15">
<div class="featured-icon-box icon-align-top-content ttm-bgcolor-darkgrey ttm-textcolor-white style12">
<div class="featured-icon">
@ -58,13 +58,13 @@
</div>
<div class="featured-content">
<div class="featured-title">
<h3>{{$popup->title}}</h3>
<h3>{{$about->title}}</h3>
</div>
<div class="featured-desc">
{!!$popup->description!!}
{{$about->description}}
</div>
<div class="featured-bottom">
<a href="programs.php">{{$popup->button_title}}</a>
<a href="programs.php">{{$about->button_text}}</a>
</div>
</div>
</div>

View File

@ -0,0 +1,82 @@
<!--service-section-->
<section class="ttm-row services-section ttm-bgcolor-grey clearfix">
<div class="container">
{{-- @dd($services) --}}
<div class="row">
<div class="col-lg-6 m-auto">
<!-- section title -->
<div class="section-title title-style-center_text">
<div class="title-header">
<h3>SERVICES WE PROVIDE</h3>
<h2 class="title">Take The Road To A Healthy Heart Beat</h2>
</div>
</div><!-- section title end -->
</div>
</div>
<div class="row slick_slider" data-slick='{"slidesToShow": 3, "slidesToScroll": 1, "arrows":false, "dots":false, "autoplay":true, "infinite":true, "responsive": [{"breakpoint":1020,"settings":{"slidesToShow": 2}} , {"breakpoint":768,"settings":{"slidesToShow": 2}}, {"breakpoint":575,"settings":{"slidesToShow": 1}}]}'>
@foreach($services as $service)
<div class="col-md-4">
<div class="featured-icon-box icon-align-top-content style1">
<div class="featured-icon">
<img class="img-fluid" src="{{asset('storage/' . $service->image)}}" width="85" height="85" alt="">
</div>
<div class="featured-content">
<div class="featured-title">
<h3><a href="programs.php">{{$service->title}}</a></h3>
</div>
<div class="featured-desc">
<p>{{$service->description}}</p>
</div>
</div>
<div class="fetured-bottom">
<a href="programs.php" class="ttm-icon ttm-icon_element-onlytxt ttm-icon_element-color-white ttm-icon_element-size-lg">
<i class="flaticon flaticon-exit"></i>
</a>
</div>
</div >
</div>
@endforeach
{{-- <div class="col-md-4">
<div class="featured-icon-box icon-align-top-content style1">
<div class="featured-icon">
<img class="img-fluid" src="images/nurse.webp" width="85" height="85" alt="">
</div>
<div class="featured-content">
<div class="featured-title">
<h3><a href="programs.php">GREEN CARD SPONSORSHIP</a></h3>
</div>
<div class="featured-desc">
<p>We cover all the expenses associated with your immigration process, including legal fees, US Government fees, as well..</p>
</div>
</div>
<div class="fetured-bottom">
<a href="programs.php" class="ttm-icon ttm-icon_element-onlytxt ttm-icon_element-color-white ttm-icon_element-size-lg">
<i class="flaticon flaticon-exit"></i>
</a>
</div>
</div >
</div>
<div class="col-md-4">
<div class="featured-icon-box icon-align-top-content style1">
<div class="featured-icon">
<img class="img-fluid" src="images/toefl.png" width="85" height="85" alt="">
</div>
<div class="featured-content">
<div class="featured-title">
<h3><a href="programs.php">IELTS/TOEFL PREPARATION</a></h3>
</div>
<div class="featured-desc">
<p>We help you prepare for IELTS/TOEFL to make you ready and capable to flourish your nursing dreams across the world by...</p>
</div>
</div>
<div class="fetured-bottom">
<a href="programs.php" class="ttm-icon ttm-icon_element-onlytxt ttm-icon_element-color-white ttm-icon_element-size-lg">
<i class="flaticon flaticon-exit"></i>
</a>
</div>
</div >
</div> --}}
</div>
</div>
</section>
<!--service-section end-->

View File

@ -47,6 +47,12 @@
<li class="nav-item">
<a class="nav-link" href="{{ route('preparations.index') }}">Preparations</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('services.index') }}">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('abouts.index') }}">Abouts</a>
</li>
</ul>
<ul class="navbar-nav ms-auto">

View File

@ -0,0 +1,30 @@
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Add Services</h1>
<form action="{{ route('services.store') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="form-group mb-3">
<label for="title">Title</label>
<input type="text" name="title" class="form-control">
</div>
<div class="form-group mb-3">
<label for="description">Description</label>
<textarea name="description" rows="5"class="form-control"></textarea>
</div>
<div class="form-group mb-3">
<label for="image">Image</label>
<input type="file" name="image" class="form-control">
</div>
<div class="form-group mb-3">
<label for="button_url">Button URL</label>
<input type="url" name="button_url" class="form-control">
</div>
<button type="submit" class="btn btn-success">Save</button>
<a href="{{ route('services.index') }}" class="btn btn-secondary">Cancel</a>
</form>
</div>
@endsection

View File

@ -0,0 +1,40 @@
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Service</h1>
<form action="{{ route('services.update', $service->id) }}" method="POST" enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="form-group mb-2">
<label>Title</label>
<input type="text" name="title" class="form-control" value="{{ $service->title }}">
</div>
<div class="form-group mb-2">
<label>Description</label>
<textarea name="description" class="form-control">{{ $service->description }}</textarea>
</div>
<div class="form-group mb-2">
<label>Button URL</label>
<input type="url" name="button_url" class="form-control" value="{{ $service->button_url }}">
</div>
<div class="form-group mb-2">
<label>Image</label>
<input type="file" name="image" class="form-control">
@if($service->image)
<div class="mt-2">
<img src="{{ asset('storage/' . $service->image) }}" width="150">
</div>
@endif
</div>
<button class="btn btn-success">Update</button>
<a href="{{ route('services.index') }}" class="btn btn-secondary">Cancel</a>
</form>
</div>
@endsection

View File

@ -0,0 +1,48 @@
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Services</h1>
<a href="{{ route('services.create') }}" class="btn btn-primary mb-3">+ Add New Service</a>
@if(session('success'))
<div class="alert alert-success">{{ session('success') }}</div>
@endif
<table class="table table-bordered">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Button URL</th>
<th>Image</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($services as $service)
<tr>
<td>{{ $service->title }}</td>
<td>{{ Str::limit($service->description, 100) }}</td>
<td><a href="{{ $service->button_url }}" target="_blank">{{ $service->button_url }}</a></td>
<td>
@if($service->image)
<img src="{{ asset('storage/' . $service->image) }}" width="100">
@endif
</td>
<td>
<a href="{{ route('services.show', $service->id) }}" class="btn btn-sm btn-info">Show</a>
<a href="{{ route('services.edit', $service->id) }}" class="btn btn-sm btn-warning">Edit</a>
<form action="{{ route('services.destroy', $service->id) }}" method="POST" style="display:inline-block;">
@csrf
@method('DELETE')
<button class="btn btn-sm btn-danger" onclick="return confirm('Delete this?')">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

View File

@ -0,0 +1,16 @@
@extends('layouts.app')
@section('content')
<div class="container">
<h1>{{ $service->title }}</h1>
<p>{{ $service->description }}</p>
@if($service->image)
<img src="{{ asset('storage/' . $service->image) }}" width="300">
@endif
@if($service->button_url)
<p><a href="{{ $service->button_url }}" target="_blank" class="btn btn-info">Visit</a></p>
@endif
</div>
@endsection

View File

@ -7,6 +7,8 @@ use App\Http\Controllers\PostController;
use App\http\Controllers\FrontendController;
use App\Http\Controllers\SliderController;
use App\Http\Controllers\PreparationController;
use App\Http\Controllers\ServiceController;
use App\Http\Controllers\AboutController;
Route::get('/', [FrontendController::class, 'homePage'])->name('home');
Route::get('/about', [FrontendController::class, 'aboutPage'])->name('about');
@ -22,6 +24,8 @@ Route::middleware('auth')->group(function () {
Route::resource('posts', PostController::class);
Route::resource('sliders', SliderController::class);
Route::resource('preparations', PreparationController::class);
Route::resource('services',ServiceController::class);
Route::resource('abouts', AboutController::class);
});
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])->name('logout');