save to codehub
This commit is contained in:
81
app/Http/Controllers/Admin/TestimonialController.php
Normal file
81
app/Http/Controllers/Admin/TestimonialController.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\Admin\ManageTestimonialService;
|
||||
use App\Models\Testimonial;
|
||||
use App\Models\TestimonialImages;
|
||||
use File;
|
||||
use Validator;
|
||||
|
||||
class TestimonialController extends Controller {
|
||||
|
||||
public function __construct(ManageTestimonialService $manageTestimonialService) {
|
||||
$this->manageTestimonialService = $manageTestimonialService;
|
||||
}
|
||||
|
||||
public function create_testimonial()
|
||||
{
|
||||
return view('Admin.Pages.manage_cms.testimonial.add_testimonial');
|
||||
}
|
||||
|
||||
public function insert_testimonial(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$testimonial = $this->manageTestimonialService->insert_testimonial($request);
|
||||
|
||||
if(!empty($testimonial))
|
||||
{
|
||||
return response()->json(['success' => true , 'status' => 200]);
|
||||
}
|
||||
else{
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo 'Message: ' .$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function view_testimonial(Request $request) {
|
||||
$testimonials = $this->manageTestimonialService->view_testimonial($request)->toArray();
|
||||
// echo "<pre>"; print_r($testimonials);exit;
|
||||
return view('Admin.Pages.manage_cms.testimonial.testimonial')->with(['data' => $testimonials]);
|
||||
// return response()->json(['success' => true,'status'=>200]);
|
||||
}
|
||||
|
||||
public function delete_testimonial($id) {
|
||||
// print_r($id);die;
|
||||
$testimonials = Testimonial::find($id)->delete();
|
||||
}
|
||||
|
||||
public function edit_testimonial($id)
|
||||
{
|
||||
$data = $this->manageTestimonialService->edit_testimonial($id)->toArray();
|
||||
// dd($data);
|
||||
return view('Admin.Pages.manage_cms.testimonial.edit_testimonial')->with(['data'=>$data]);
|
||||
|
||||
}
|
||||
|
||||
public function update_testimonial(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->manageTestimonialService->update_testimonial($request);
|
||||
if(!empty($data)){
|
||||
return response()->json(['success' => true , 'status' => 200]);
|
||||
}
|
||||
else{
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo 'Message: ' .$e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user