testimonial done
This commit is contained in:
@ -10,6 +10,7 @@ use App\Models\Slider;
|
||||
use App\Models\Preparation;
|
||||
use App\Models\Service;
|
||||
use App\Models\About;
|
||||
use App\Models\Testimonial;
|
||||
|
||||
class FrontendController extends Controller
|
||||
{
|
||||
@ -20,7 +21,7 @@ class FrontendController extends Controller
|
||||
$data['services'] = Service::all();
|
||||
$data['abouts'] = About::all();
|
||||
// $data['contact'] = Contact::first();
|
||||
// $data['testimonials'] = Testimonial::all();
|
||||
$data['testimonials'] = Testimonial::all();
|
||||
// $data['partners'] = Partner::all();
|
||||
// $data['passers'] = Passer::all();
|
||||
// $data['blogs'] = Blog::latest()->take(3)->get();
|
||||
|
88
app/Http/Controllers/TestimonialController.php
Normal file
88
app/Http/Controllers/TestimonialController.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Testimonial;
|
||||
|
||||
class TestimonialController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$testimonials = Testimonial::all();
|
||||
return view('testimonials.index', compact('testimonials'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('testimonials.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:225',
|
||||
'message' => 'required|string',
|
||||
'image' => 'nullable|image|mimes:jpeg,png,jpg,webp|max:2048',
|
||||
]);
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$validated['image'] = $request->file('image')->store('testimonials', 'public');
|
||||
}
|
||||
|
||||
Testimonial::create($validated);
|
||||
|
||||
return redirect()->route('testimonials.index')->with('success', 'Testimonials created successfully');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$testimonial = Testimonial::findOrFail($id);
|
||||
|
||||
// Optionally delete the image from storage
|
||||
if ($testimonial->image && \Storage::disk('public')->exists($testimonial->image)) {
|
||||
\Storage::disk('public')->delete($testimonial->image);
|
||||
}
|
||||
|
||||
$testimonial->delete();
|
||||
|
||||
return redirect()->route('testimonials.index')->with('success', 'testimonial deleted successfully');
|
||||
}
|
||||
public function show($id)
|
||||
{
|
||||
$testimonial = Testimonial::findOrFail($id);
|
||||
return view('testimonials.show', compact('testimonial'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$testimonial = Testimonial::findOrFail($id);
|
||||
return view('testimonials.edit', compact('testimonial'));
|
||||
}
|
||||
|
||||
public function update(Request $request, testimonial $testimonial)
|
||||
{
|
||||
// dd($testimonial->toArray());
|
||||
$validated = $request->validate([
|
||||
'name' => 'nullable|string|max:255',
|
||||
'message' => 'nullable|string',
|
||||
'image' => 'nullable|image',
|
||||
]);
|
||||
|
||||
// If image is uploaded
|
||||
if ($request->hasFile('image')) {
|
||||
// Delete old image if exists
|
||||
if ($testimonial->image && \Storage::disk('public')->exists($testimonial->image)) {
|
||||
\Storage::disk('public')->delete($testimonial->image);
|
||||
}
|
||||
$imagePath = $request->file('image')->store('testimonials', 'public');
|
||||
$validated['image'] = $imagePath;
|
||||
}
|
||||
|
||||
$testimonial->update($validated);
|
||||
|
||||
return redirect()->route('testimonials.index')->with('success', 'testimonial updated successfully');
|
||||
}
|
||||
|
||||
}
|
||||
|
10
app/Models/testimonial.php
Normal file
10
app/Models/testimonial.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class testimonial extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'message', 'image'];
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?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('testimonials', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->text('message');
|
||||
$table->string('image');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('testimonials');
|
||||
}
|
||||
};
|
@ -11,7 +11,7 @@
|
||||
<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>
|
||||
|
||||
<a href="{{ route('testimonials.index') }}" class="btn btn-secondary">Manage Testimonials</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -7,7 +7,7 @@
|
||||
@include('frontend.partials.service', ['services' => $services])
|
||||
@include('frontend.partials.about', ['abouts' => $abouts])
|
||||
{{-- @include('frontend.partials.contact', ['contact' => $contact]) --}}
|
||||
{{-- @include('frontend.partials.testimonial', ['testimonials' => $testimonials]) --}}
|
||||
@include('frontend.partials.testimonial', ['testimonials' => $testimonials])
|
||||
{{-- @include('frontend.partials.partners', ['partners' => $partners]) --}}
|
||||
{{-- @include('frontend.partials.passers', ['passers' => $passers]) --}}
|
||||
{{-- @include('frontend.partials.blog', ['blogs' => $blogs]) --}}
|
||||
|
176
resources/views/frontend/partials/testimonial.blade.php
Normal file
176
resources/views/frontend/partials/testimonial.blade.php
Normal file
@ -0,0 +1,176 @@
|
||||
<!--consultant-section-->
|
||||
{{-- @dd($consultant_section) --}}
|
||||
<section
|
||||
class="ttm-row consultant-section bg-img2 ttm-bgcolor-dark ttm-textcolor-white ttm-bg ttm-bgimage-yes clearfix">
|
||||
<div class="ttm-row-wrapper-bg-layer ttm-bg-layer"></div>
|
||||
<div class="container">
|
||||
<div class="row row-title">
|
||||
<div class="col-lg-12 m-auto">
|
||||
<!-- section title -->
|
||||
<div class="section-title title-style-center_text style2">
|
||||
<div class="title-header">
|
||||
{{-- <h3>{{$consultant_section->title}}</h3> --}}
|
||||
{{-- <h2 class="title">{{$consultant_section->short_description}} --}}
|
||||
</h2>
|
||||
</div>
|
||||
</div><!-- section title end -->
|
||||
<div class="consutant-doc-info d-sm-flex justify-content-center align-items-center">
|
||||
<div class="pr-30 res-575-pr-0 text-center">
|
||||
{{-- <a class="ttm-btn ttm-btn-size-md ttm-btn-shape-square ttm-btn-style-border ttm-btn-color-white mt-10"
|
||||
href="contact.php" tabindex="0">{{$consultant_section->button_text}}</a> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!--consultant-section-->
|
||||
{{-- @dd($testimonials) --}}
|
||||
<!--testimonial-section-->
|
||||
<section class="ttm-row zero_padding-section testimonial-section-homepage clearfix">
|
||||
<div class="container">
|
||||
<div class="row g-0">
|
||||
<div class="col-xl-5 col-lg-12">
|
||||
<div class="box-shadow ttm-bg ttm-col-bgcolor-yes ttm-left-span ttm-bgcolor-skincolor spacing-21">
|
||||
<div class="ttm-col-wrapper-bg-layer ttm-bg-layer"></div>
|
||||
<div class="layer-content">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<!-- section title -->
|
||||
<div class="section-title mb-18">
|
||||
<div class="title-header">
|
||||
<h3 class="ttm-textcolor-white">TESTIMONIALS</h3>
|
||||
<h2 class="title">What Are They Saying</h2>
|
||||
</div>
|
||||
</div><!-- section title end -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="ttm-horizontal_sep mt-5"></div>
|
||||
<div class="featured-icon-box icon-align-before-content style20">
|
||||
<div class="featured-icon">
|
||||
<div
|
||||
class="ttm-icon ttm-icon_element-size-lg ttm-icon_element-onlytxt ttm-icon_element-color-white">
|
||||
<i class="flaticon flaticon-support"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="featured-content">
|
||||
<div class="featured-desc">
|
||||
<p>If you have any questions or need help contact<br>with our team, or call<a
|
||||
href="tel: (+977) 9851102535 "><span> (+977) 9851102535 </span></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-7 col-lg-12 res-1199-pt-0">
|
||||
<div class="box-shadow ttm-bg ttm-col-bgimage-yes ttm-right-span col-bg-img-eleven spacing-22">
|
||||
<div class="ttm-col-wrapper-bg-layer ttm-bg-layer ttm-bgcolor-darkgrey"></div>
|
||||
<div class="layer-content">
|
||||
<div class="row slick_slider slick-arrows-style1 mx-0"
|
||||
data-slick='{"slidesToShow": 1, "slidesToScroll": 1, "arrows":true, "dots":false, "autoplay":true, "infinite":true, "responsive": [{"breakpoint":1100,"settings":{"slidesToShow": 1}} , {"breakpoint":768,"settings":{"slidesToShow": 3}}, {"breakpoint":575,"settings":{"slidesToShow": 2}}]}'>
|
||||
|
||||
@foreach($testimonials as $testimonial)
|
||||
<div class="col-sm-12">
|
||||
<div class="testimonials style5 ">
|
||||
<div class="testimonial-content">
|
||||
<div class="row">
|
||||
<div class="col-md-3 align-self-center">
|
||||
<div class="testimonial-bottom">
|
||||
<div class="testimonial-avatar">
|
||||
<div class="testimonial-img">
|
||||
<img class="img-fluid" src="{{asset('storage/' . $testimonial->image)}}"
|
||||
alt="testimonial-img" width="80" height="80">
|
||||
</div>
|
||||
</div>
|
||||
<div class="testimonial-caption">
|
||||
<h3>{{$testimonial->name}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9 res-767-pt-20 res-767-pr-15">
|
||||
<div class="testimonial-desc">
|
||||
<blockquote class="testimonial-text">{{$testimonial->message}}
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
{{-- <div class="col-sm-12">
|
||||
<div class="testimonials style5 ">
|
||||
<div class="testimonial-content">
|
||||
<div class="row">
|
||||
<div class="col-md-3 align-self-center">
|
||||
<div class="testimonial-bottom">
|
||||
<div class="testimonial-avatar">
|
||||
<div class="testimonial-img">
|
||||
<img class="img-fluid" src="images/testimonial/13.jpg"
|
||||
alt="testimonial-img" width="80" height="80">
|
||||
</div>
|
||||
</div>
|
||||
<div class="testimonial-caption">
|
||||
<h3>Prapti Acharya</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9 res-767-pt-30 res-767-pr-15">
|
||||
<div class="testimonial-desc">
|
||||
<blockquote class="testimonial-text">“I am deeply grateful to NCLEX
|
||||
Center Nepal for their invaluable support, expert guidance, and
|
||||
exceptional instructors that enabled me to pass the NCLEX exam
|
||||
on my first attempt, and I wholeheartedly recommend their
|
||||
services to aspiring candidates.”</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12">
|
||||
<div class="testimonials style5 ">
|
||||
<div class="testimonial-content">
|
||||
<div class="row">
|
||||
<div class="col-md-3 align-self-center">
|
||||
<div class="testimonial-bottom">
|
||||
<div class="testimonial-avatar">
|
||||
<div class="testimonial-img">
|
||||
<img class="img-fluid" src="images/testimonial/14.jpg"
|
||||
alt="testimonial-img" width="80" height="80">
|
||||
</div>
|
||||
</div>
|
||||
<div class="testimonial-caption">
|
||||
<h3>Garima Khanal</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9 res-767-pt-30 res-767-pr-15">
|
||||
<div class="testimonial-desc">
|
||||
<blockquote class="testimonial-text">“I would like to extend my
|
||||
deepest gratitude in thanking NCLEX Center Nepal and helping me
|
||||
during my NCLEX journey. I truly appreciate your teaching and
|
||||
hope you will always continue to teach NCLEX and make difference
|
||||
in everyone’s lives.” </blockquote>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> --}}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!--testimonial-section-end-->
|
@ -53,6 +53,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('abouts.index') }}">Abouts</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('testimonials.index') }}">Testimonials</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="navbar-nav ms-auto">
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Add Slider</h1>
|
||||
<h1>Edit Slider</h1>
|
||||
<form method="POST" action="{{ route('sliders.update', $slider->id) }}" enctype="multipart/form-data">
|
||||
@csrf @method('PUT')
|
||||
|
||||
|
24
resources/views/testimonials/create.blade.php
Normal file
24
resources/views/testimonials/create.blade.php
Normal file
@ -0,0 +1,24 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Add Testimonial</h1>
|
||||
<form action="{{ route('testimonials.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="form-group mb-3">
|
||||
<label for="name">Name</label>
|
||||
<input type="text" name="name" class="form-control">
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label for="message">Message</label>
|
||||
<textarea name="message" rows="5" class="form-control"></textarea>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label for="image">Profile Picture</label>
|
||||
<input type="file" name="image" class="form-control">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">Save</button>
|
||||
<a href="{{ route('testimonials.index') }}" class="btn btn-secondary">Cancel</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
27
resources/views/testimonials/edit.blade.php
Normal file
27
resources/views/testimonials/edit.blade.php
Normal file
@ -0,0 +1,27 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Edit Testimonial</h1>
|
||||
<form method="POST" action="{{ route('testimonials.update', $testimonial->id) }}" enctype="multipart/form-data">
|
||||
@csrf @method('PUT')
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="name" class="form-label">Name</label>
|
||||
<input type="text" name="name" class="form-control" value="{{ $testimonial->name}}">
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label for="message" class="form-label">Message</label>
|
||||
<textarea name="message" rows="5" class="form-control">{{ $testimonial->message }}</textarea>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label for="image">Profile Picture</label>
|
||||
<input type="file" name="image" class="form-control">
|
||||
@if ($testimonial->image)
|
||||
<p>Current image: <img src="{{ asset('storage/' . $testimonial->image) }}" width="150"></p>
|
||||
@endif
|
||||
</div>
|
||||
<button class="btn btn-success">Update</button>
|
||||
<a href="{{ route('testimonials.index') }}" class="btn btn-danger">Cancel</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
49
resources/views/testimonials/index.blade.php
Normal file
49
resources/views/testimonials/index.blade.php
Normal file
@ -0,0 +1,49 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Testimonials</h1>
|
||||
|
||||
<a href="{{ route('testimonials.create') }}" class="btn btn-primary mb-3">Create New Testimonial</a>
|
||||
|
||||
@if(session('success'))
|
||||
<div class="alert alert-success">{{ session('success') }}</div>
|
||||
@endif
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Message</th>
|
||||
<th>Profile Picture</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($testimonials as $testimonial)
|
||||
<tr>
|
||||
<td>{{ $testimonial->name }}</td>
|
||||
<td>{{ \Illuminate\Support\Str::limit($testimonial->message, 50) }}</td>
|
||||
<td>
|
||||
@if($testimonial->image)
|
||||
<img src="{{ asset('storage/' . $testimonial->image) }}" alt="bg-img" width="100">
|
||||
@else
|
||||
N/A
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('testimonials.show', $testimonial->id) }}" class="btn btn-sm btn-info">View</a>
|
||||
<a href="{{ route('testimonials.edit', $testimonial->id) }}" class="btn btn-sm btn-warning">Edit</a>
|
||||
<form action="{{ route('testimonials.destroy', $testimonial->id) }}" method="POST" style="display:inline-block">
|
||||
@csrf @method('DELETE')
|
||||
<button class="btn btn-sm btn-danger" onclick="return confirm('Delete this testimonial?')">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="3">No testimonials found.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
21
resources/views/testimonials/show.blade.php
Normal file
21
resources/views/testimonials/show.blade.php
Normal file
@ -0,0 +1,21 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Testimonial Details</h1>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item"><strong>Name:</strong> {{ $testimonial->name }}</li>
|
||||
<li class="list-group-item"><strong>Message:</strong>{{ $testimonial->message}}</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Profile Picture</strong>
|
||||
@if($testimonial->image)
|
||||
<img src="{{ Storage::url($testimonial->image) }}" alt="bg-img" width="100">
|
||||
@else
|
||||
N/A
|
||||
@endif
|
||||
</li>
|
||||
</ul>
|
||||
<a href="{{ route('testimonials.edit', $testimonial->id) }}" class="btn btn-warning">Edit</a>
|
||||
<a href="{{ route('testimonials.index') }}" class="btn btn-secondary mt-3">Back to List</a>
|
||||
</div>
|
||||
@endsection
|
@ -9,6 +9,7 @@ use App\Http\Controllers\SliderController;
|
||||
use App\Http\Controllers\PreparationController;
|
||||
use App\Http\Controllers\ServiceController;
|
||||
use App\Http\Controllers\AboutController;
|
||||
use App\Http\Controllers\TestimonialController;
|
||||
|
||||
Route::get('/', [FrontendController::class, 'homePage'])->name('home');
|
||||
Route::get('/aboutpage', [FrontendController::class, 'aboutPage'])->name('aboutpage');
|
||||
@ -26,6 +27,7 @@ Route::middleware('auth')->group(function () {
|
||||
Route::resource('preparations', PreparationController::class);
|
||||
Route::resource('services',ServiceController::class);
|
||||
Route::resource('abouts', AboutController::class);
|
||||
Route::resource('testimonials', TestimonialController::class);
|
||||
});
|
||||
|
||||
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])->name('logout');
|
||||
|
Reference in New Issue
Block a user