diff --git a/app/Http/Controllers/FrontendController.php b/app/Http/Controllers/FrontendController.php index 25fe538..a261749 100644 --- a/app/Http/Controllers/FrontendController.php +++ b/app/Http/Controllers/FrontendController.php @@ -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(); diff --git a/app/Http/Controllers/TestimonialController.php b/app/Http/Controllers/TestimonialController.php new file mode 100644 index 0000000..ca065c9 --- /dev/null +++ b/app/Http/Controllers/TestimonialController.php @@ -0,0 +1,88 @@ +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'); + } + +} + diff --git a/app/Models/testimonial.php b/app/Models/testimonial.php new file mode 100644 index 0000000..8e5167a --- /dev/null +++ b/app/Models/testimonial.php @@ -0,0 +1,10 @@ +id(); + $table->string('name'); + $table->text('message'); + $table->string('image'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('testimonials'); + } +}; diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 5146464..0a64709 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -11,7 +11,7 @@ Manage Preparations Manage Services Manage Abouts - + Manage Testimonials diff --git a/resources/views/frontend/home.blade.php b/resources/views/frontend/home.blade.php index 7523e6a..924d755 100644 --- a/resources/views/frontend/home.blade.php +++ b/resources/views/frontend/home.blade.php @@ -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]) --}} diff --git a/resources/views/frontend/partials/testimonial.blade.php b/resources/views/frontend/partials/testimonial.blade.php new file mode 100644 index 0000000..dd1f56a --- /dev/null +++ b/resources/views/frontend/partials/testimonial.blade.php @@ -0,0 +1,176 @@ + +{{-- @dd($consultant_section) --}} +
+
+
+
+
+ +
+
+ {{--

{{$consultant_section->title}}

--}} + {{--

{{$consultant_section->short_description}} --}} +

+
+
+ +
+
+
+
+ +{{-- @dd($testimonials) --}} + +
+
+
+
+
+
+
+
+
+ +
+
+

TESTIMONIALS

+

What Are They Saying

+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ + @foreach($testimonials as $testimonial) +
+
+
+
+
+
+
+
+ testimonial-img +
+
+
+

{{$testimonial->name}}

+
+
+
+
+
+
{{$testimonial->message}} +
+
+
+
+
+
+
+ @endforeach + {{--
+
+
+
+
+
+
+
+ testimonial-img +
+
+
+

Prapti Acharya

+
+
+
+
+
+
“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.”
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ testimonial-img +
+
+
+

Garima Khanal

+
+
+
+
+
+
“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.”
+
+
+
+
+
+ +
--}} + +
+ +
+
+
+
+
+ +
+ diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index d50710e..0d9dd43 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -53,6 +53,9 @@ +