diff --git a/app/Helpers/LMS.php b/app/Helpers/LMS.php index 5aa1a47..20b59c6 100644 --- a/app/Helpers/LMS.php +++ b/app/Helpers/LMS.php @@ -593,6 +593,34 @@ class LMS { static $initialized = false; if (!$initialized) { + DB::statement("CREATE TABLE IF NOT EXISTS `tbl_logos` ( + `logo_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, + `logo` VARCHAR(255), + `link` VARCHAR(255), + `display_order` INT(11), + `status` INT(11), + `remarks` TEXT, + `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP, + `createdby` INT(11), + `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `updatedby` INT(11) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + "); + DB::statement("CREATE TABLE IF NOT EXISTS `tbl_testimonials` ( + `testimonial_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, + `video_url` VARCHAR(255), + `review` VARCHAR(255), + `name` VARCHAR(20) NOT NULL, + `designation` VARCHAR(100), + `display_order` INT(11), + `status` INT(11), + `remarks` TEXT, + `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP, + `createdby` INT(11), + `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `updatedby` INT(11) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + "); DB::statement("CREATE TABLE IF NOT EXISTS `tbl_contactus` ( `inquiries_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `title` VARCHAR(255), @@ -1595,6 +1623,12 @@ class LMS $table->string('photo')->nullable(); }); } + if (!Schema::hasColumn('campaignarticles', 'sub_title')) { + Schema::table('campaignarticles', function (Blueprint $table) { + // Add the new column to the table + $table->string('sub_title')->nullable()->after('title'); + }); + } $initialized = true; } diff --git a/app/Http/Controllers/CampaignarticlesController.php b/app/Http/Controllers/CampaignarticlesController.php index 712d05c..1d281bf 100644 --- a/app/Http/Controllers/CampaignarticlesController.php +++ b/app/Http/Controllers/CampaignarticlesController.php @@ -144,7 +144,7 @@ DB::beginTransaction(); try { $OperationNumber = getOperationNumber(); - $this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('campaignarticle_id')); + $this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id); } catch (Exception $e) { DB::rollBack(); Log::info($e->getMessage()); diff --git a/app/Http/Controllers/FileController.php b/app/Http/Controllers/FileController.php new file mode 100644 index 0000000..fb5c117 --- /dev/null +++ b/app/Http/Controllers/FileController.php @@ -0,0 +1,20 @@ +file('upload'); + $filename = uniqid() . '_' . $file->getClientOriginalName(); + Storage::disk('public')->put($filename, file_get_contents($file)); + $url = asset('storage/' . $filename); + return response()->json([ + 'url' => $url, + ]); + } +} diff --git a/app/Http/Controllers/LogosController.php b/app/Http/Controllers/LogosController.php new file mode 100644 index 0000000..759d7a1 --- /dev/null +++ b/app/Http/Controllers/LogosController.php @@ -0,0 +1,200 @@ +modelService = new CommonModelService($model); + } + public function index(Request $request) + { + createActivityLog(LogosController::class, 'index', ' Logos index'); + $data = Logos::where('status','<>',-1)->orderBy('display_order')->get(); + + return view("crud.generated.logos.index", compact('data')); + } + + public function create(Request $request) + { + createActivityLog(LogosController::class, 'create', ' Logos create'); + $TableData = Logos::where('status','<>',-1)->orderBy('display_order')->get(); + return view("crud.generated.logos.create",compact('TableData')); + } + + public function store(Request $request) + { + createActivityLog(LogosController::class, 'store', ' Logos store'); + $validator = Validator::make($request->all(), [ + //ADD REQUIRED FIELDS FOR VALIDATION + ]); + + if ($validator->fails()) { + return response()->json([ + 'error' => $validator->errors(), + ],500); + } + $request->request->add(['alias' => slugify($request->title)]); + $request->request->add(['display_order' => getDisplayOrder('tbl_logos')]); + $request->request->add(['created_at' => date("Y-m-d h:i:s")]); + $request->request->add(['updated_at' => date("Y-m-d h:i:s")]); + $requestData=$request->all(); + array_walk_recursive($requestData, function (&$value) { + $value = str_replace(env('APP_URL').'/', '', $value); + }); + array_walk_recursive($requestData, function (&$value) { + $value = str_replace(env('APP_URL'), '', $value); + }); + DB::beginTransaction(); + try { + $operationNumber = getOperationNumber(); + $this->modelService->create($operationNumber, $operationNumber, null, $requestData); + } catch (\Exception $e) { + DB::rollBack(); + Log::info($e->getMessage()); + createErrorLog(LogosController::class, 'store', $e->getMessage()); + return response()->json(['status' => false, 'message' => $e->getMessage()], 500); + } + DB::commit(); + if ($request->ajax()) { + return response()->json(['status' => true, 'message' => 'The Logos Created Successfully.'], 200); + } + return redirect()->route('logos.index')->with('success','The Logos created Successfully.'); + } + + public function sort(Request $request) + { + $idOrder = $request->input('id_order'); + + foreach ($idOrder as $index => $id) { + $companyArticle = Logos::find($id); + $companyArticle->display_order = $index + 1; + $companyArticle->save(); + } + + return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200); + } + public function updatealias(Request $request) + { + + $articleId = $request->input('articleId'); + $newAlias = $request->input('newAlias'); + $companyArticle = Logos::find($articleId); + if (!$companyArticle) { + return response()->json(['status' => false, 'content' => 'Company article not found.'], 404); + } + $companyArticle->alias = $newAlias; + $companyArticle->save(); + return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200); + } + + + + + public function show(Request $request, $id) + { + createActivityLog(LogosController::class, 'show', ' Logos show'); + $data = Logos::findOrFail($id); + + return view("crud.generated.logos.show", compact('data')); + } + + + public function edit(Request $request, $id) + { + createActivityLog(LogosController::class, 'edit', ' Logos edit'); + $TableData = Logos::where('status','<>',-1)->orderBy('display_order')->get(); + $data = Logos::findOrFail($id); + if ($request->ajax()) { + $html = view("crud.generated.logos.ajax.edit", compact('data'))->render(); + return response()->json(['status' => true, 'content' => $html], 200); + } + return view("crud.generated.logos.edit", compact('data','TableData')); + } + + + public function update(Request $request, $id) + { + createActivityLog(LogosController::class, 'update', ' Logos update'); + $validator = Validator::make($request->all(), [ + //ADD VALIDATION FOR REQIRED FIELDS + ]); + + if ($validator->fails()) { + return response()->json([ + 'error' => $validator->errors(), + ],500); + } + $requestData=$request->all(); + array_walk_recursive($requestData, function (&$value) { + $value = str_replace(env('APP_URL').'/', '', $value); + }); + array_walk_recursive($requestData, function (&$value) { + $value = str_replace(env('APP_URL'), '', $value); + }); + DB::beginTransaction(); + try { + $OperationNumber = getOperationNumber(); + $this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('logo_id')); + } catch (Exception $e) { + DB::rollBack(); + Log::info($e->getMessage()); + createErrorLog(LogosController::class, 'update', $e->getMessage()); + return response()->json(['status' => false, 'message' => $e->getMessage()], 500); + } + DB::commit(); + if ($request->ajax()) { + return response()->json(['status' => true, 'message' => 'The Logos updated Successfully.'], 200); + } + // return redirect()->route('logos.index')->with('success','The Logos updated Successfully.'); + return redirect()->back()->with('success', 'The Logos updated successfully.'); + } + + public function destroy(Request $request,$id) + { + createActivityLog(LogosController::class, 'destroy', ' Logos destroy'); + DB::beginTransaction(); + try { + $OperationNumber = getOperationNumber(); + $this->modelService->destroy($OperationNumber, $OperationNumber, $id); + } catch (Exception $e) { + DB::rollBack(); + Log::info($e->getMessage()); + createErrorLog(LogosController::class, 'destroy', $e->getMessage()); + return response()->json(['status' => false, 'message' => $e->getMessage()], 500); + } + DB::commit(); + return response()->json(['status'=>true,'message'=>'The Logos Deleted Successfully.'],200); + } + public function toggle(Request $request,$id) + { + createActivityLog(LogosController::class, 'destroy', ' Logos destroy'); + $data = Logos::findOrFail($id); + $requestData=['status'=>($data->status==1)?0:1]; + DB::beginTransaction(); + try { + $OperationNumber = getOperationNumber(); + $this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id); + } catch (Exception $e) { + DB::rollBack(); + Log::info($e->getMessage()); + createErrorLog(LogosController::class, 'destroy', $e->getMessage()); + return response()->json(['status' => false, 'message' => $e->getMessage()], 500); + } + DB::commit(); + return response()->json(['status'=>true,'message'=>'The Logos Deleted Successfully.'],200); + } + + + + } + \ No newline at end of file diff --git a/app/Http/Controllers/RegistrationsController.php b/app/Http/Controllers/RegistrationsController.php index 129754d..abca00b 100644 --- a/app/Http/Controllers/RegistrationsController.php +++ b/app/Http/Controllers/RegistrationsController.php @@ -6,8 +6,11 @@ use App\Http\Controllers\Controller; use App\Mail\CustomMailer; use App\Models\Agents; use App\Models\Campaigns; +use App\Models\Campaignarticles; +use App\Models\Testimonials; use App\Models\Countries; use App\Models\Leadcategories; +use App\Models\Logos; use Illuminate\Http\Request; use App\Models\Registrations; use App\Models\Sources; @@ -18,6 +21,7 @@ use App\Service\CommonModelService; use Exception; use Illuminate\Support\Facades\Mail; use LMS; +use Illuminate\Support\Facades\View; use NewRegistrationAdminNotification; class RegistrationsController extends Controller @@ -26,6 +30,16 @@ class RegistrationsController extends Controller public function __construct(Registrations $model) { $this->modelService = new CommonModelService($model); + $articles = Campaignarticles::where('status', 1)->latest()->get(); + $testimonials = Testimonials::where('status', 1)->latest()->get(); + $logos = Logos::where('status',1)->latest()->get(); + + View::share([ + 'articles'=> $articles, + 'testimonials'=>$testimonials, + 'logos'=>$logos, + + ]); } public function index(Request $request) { @@ -225,20 +239,31 @@ class RegistrationsController extends Controller } if ($Campaign != null) { $viewPath = env("CLIENT_PATH") . ".landing"; - if (view()->exists($viewPath)) + if (view()->exists($viewPath)) { return view($viewPath, compact("Campaign")); - else + } else { + // dd($article); return view(env("CLIENT_PATH") . '.home', compact("Campaign")); + } } else { $Campaign = LMS::getActiveCampaign(); $viewPath = env("CLIENT_PATH") . ".landing"; - if (view()->exists($viewPath)) + if (view()->exists($viewPath)) { return view($viewPath, compact("Campaign")); - else + } else { return view(env("CLIENT_PATH") . '.home', compact("Campaign")); + } } } } + public function getTestimonial() + { + + + $testimonials = Testimonials::where('status', 1)->latest()->get(); + // dd($testimonials); + return response()->json($testimonials); + } public function reception(Request $request) { //Office ko Reception Bata directly fill-in garne form diff --git a/app/Http/Controllers/TestimonialsController.php b/app/Http/Controllers/TestimonialsController.php new file mode 100644 index 0000000..9f88e99 --- /dev/null +++ b/app/Http/Controllers/TestimonialsController.php @@ -0,0 +1,201 @@ +modelService = new CommonModelService($model); + } + public function index(Request $request) + { + createActivityLog(TestimonialsController::class, 'index', ' Testimonials index'); + $data = Testimonials::where('status','<>',-1)->orderBy('display_order')->get(); + + return view("crud.generated.testimonials.index", compact('data')); + } + + public function create(Request $request) + { + createActivityLog(TestimonialsController::class, 'create', ' Testimonials create'); + $TableData = Testimonials::where('status','<>',-1)->orderBy('display_order')->get(); + return view("crud.generated.testimonials.create",compact('TableData')); + } + + public function store(Request $request) + { + createActivityLog(TestimonialsController::class, 'store', ' Testimonials store'); + $validator = Validator::make($request->all(), [ + //ADD REQUIRED FIELDS FOR VALIDATION + ]); + + if ($validator->fails()) { + return response()->json([ + 'error' => $validator->errors(), + ],500); + } + $request->request->add(['alias' => slugify($request->title)]); + $request->request->add(['display_order' => getDisplayOrder('tbl_testimonials')]); + $request->request->add(['created_at' => date("Y-m-d h:i:s")]); + $request->request->add(['updated_at' => date("Y-m-d h:i:s")]); + $requestData=$request->all(); + array_walk_recursive($requestData, function (&$value) { + $value = str_replace(env('APP_URL').'/', '', $value); + }); + array_walk_recursive($requestData, function (&$value) { + $value = str_replace(env('APP_URL'), '', $value); + }); + DB::beginTransaction(); + try { + $operationNumber = getOperationNumber(); + $this->modelService->create($operationNumber, $operationNumber, null, $requestData); + } catch (\Exception $e) { + DB::rollBack(); + Log::info($e->getMessage()); + createErrorLog(TestimonialsController::class, 'store', $e->getMessage()); + return response()->json(['status' => false, 'message' => $e->getMessage()], 500); + } + DB::commit(); + if ($request->ajax()) { + return response()->json(['status' => true, 'message' => 'The Testimonials Created Successfully.'], 200); + } + return redirect()->route('testimonials.index')->with('success','The Testimonials created Successfully.'); + } + + public function sort(Request $request) + { + $idOrder = $request->input('id_order'); + + foreach ($idOrder as $index => $id) { + $companyArticle = Testimonials::find($id); + $companyArticle->display_order = $index + 1; + $companyArticle->save(); + } + + return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200); + } + public function updatealias(Request $request) + { + + $articleId = $request->input('articleId'); + $newAlias = $request->input('newAlias'); + $companyArticle = Testimonials::find($articleId); + if (!$companyArticle) { + return response()->json(['status' => false, 'content' => 'Company article not found.'], 404); + } + $companyArticle->alias = $newAlias; + $companyArticle->save(); + return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200); + } + + + + + public function show(Request $request, $id) + { + createActivityLog(TestimonialsController::class, 'show', ' Testimonials show'); + $data = Testimonials::findOrFail($id); + + return view("crud.generated.testimonials.show", compact('data')); + } + + + public function edit(Request $request, $id) + { + createActivityLog(TestimonialsController::class, 'edit', ' Testimonials edit'); + $TableData = Testimonials::where('status','<>',-1)->orderBy('display_order')->get(); + $data = Testimonials::findOrFail($id); + if ($request->ajax()) { + $html = view("crud.generated.testimonials.ajax.edit", compact('data'))->render(); + return response()->json(['status' => true, 'content' => $html], 200); + } + return view("crud.generated.testimonials.edit", compact('data','TableData')); + } + + + public function update(Request $request, $id) + { + // dd($request->all()); + createActivityLog(TestimonialsController::class, 'update', ' Testimonials update'); + $validator = Validator::make($request->all(), [ + //ADD VALIDATION FOR REQIRED FIELDS + ]); + + if ($validator->fails()) { + return response()->json([ + 'error' => $validator->errors(), + ],500); + } + $requestData=$request->all(); + array_walk_recursive($requestData, function (&$value) { + $value = str_replace(env('APP_URL').'/', '', $value); + }); + array_walk_recursive($requestData, function (&$value) { + $value = str_replace(env('APP_URL'), '', $value); + }); + DB::beginTransaction(); + try { + $OperationNumber = getOperationNumber(); + $this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id); + } catch (Exception $e) { + DB::rollBack(); + Log::info($e->getMessage()); + createErrorLog(TestimonialsController::class, 'update', $e->getMessage()); + return response()->json(['status' => false, 'message' => $e->getMessage()], 500); + } + DB::commit(); + if ($request->ajax()) { + return response()->json(['status' => true, 'message' => 'The Testimonials updated Successfully.'], 200); + } + // return redirect()->route('testimonials.index')->with('success','The Testimonials updated Successfully.'); + return redirect()->back()->with('success', 'The Testimonials updated successfully.'); + } + + public function destroy(Request $request,$id) + { + createActivityLog(TestimonialsController::class, 'destroy', ' Testimonials destroy'); + DB::beginTransaction(); + try { + $OperationNumber = getOperationNumber(); + $this->modelService->destroy($OperationNumber, $OperationNumber, $id); + } catch (Exception $e) { + DB::rollBack(); + Log::info($e->getMessage()); + createErrorLog(TestimonialsController::class, 'destroy', $e->getMessage()); + return response()->json(['status' => false, 'message' => $e->getMessage()], 500); + } + DB::commit(); + return response()->json(['status'=>true,'message'=>'The Testimonials Deleted Successfully.'],200); + } + public function toggle(Request $request,$id) + { + createActivityLog(TestimonialsController::class, 'destroy', ' Testimonials destroy'); + $data = Testimonials::findOrFail($id); + $requestData=['status'=>($data->status==1)?0:1]; + DB::beginTransaction(); + try { + $OperationNumber = getOperationNumber(); + $this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id); + } catch (Exception $e) { + DB::rollBack(); + Log::info($e->getMessage()); + createErrorLog(TestimonialsController::class, 'destroy', $e->getMessage()); + return response()->json(['status' => false, 'message' => $e->getMessage()], 500); + } + DB::commit(); + return response()->json(['status'=>true,'message'=>'The Testimonials Deleted Successfully.'],200); + } + + + + } + \ No newline at end of file diff --git a/app/Models/Campaignarticles.php b/app/Models/Campaignarticles.php index cb03113..f784d0c 100644 --- a/app/Models/Campaignarticles.php +++ b/app/Models/Campaignarticles.php @@ -1,42 +1,44 @@ status == 1 ? ' Active ' : 'Inactive'; - } + ]; + + protected $appends = ['status_name']; + + protected function getStatusNameAttribute() + { + return $this->status == 1 ? ' Active ' : 'Inactive'; + } protected function createdBy(): Attribute { @@ -51,4 +53,4 @@ get: fn ($value) => User::find($value) ? User::find($value)->name : '', ); } - } \ No newline at end of file +} diff --git a/app/Models/Logos.php b/app/Models/Logos.php new file mode 100644 index 0000000..7bf543d --- /dev/null +++ b/app/Models/Logos.php @@ -0,0 +1,49 @@ +status == 1 ? ' Active ' : 'Inactive'; + } + + protected function createdBy(): Attribute + { + return Attribute::make( + get: fn ($value) => User::find($value) ? User::find($value)->name : '', + ); + } + + protected function updatedBy(): Attribute + { + return Attribute::make( + get: fn ($value) => User::find($value) ? User::find($value)->name : '', + ); + } + } \ No newline at end of file diff --git a/app/Models/Testimonials.php b/app/Models/Testimonials.php new file mode 100644 index 0000000..eb4d5c8 --- /dev/null +++ b/app/Models/Testimonials.php @@ -0,0 +1,52 @@ +status == 1 ? ' Active ' : 'Inactive'; + } + + protected function createdBy(): Attribute + { + return Attribute::make( + get: fn ($value) => User::find($value) ? User::find($value)->name : '', + ); + } + + protected function updatedBy(): Attribute + { + return Attribute::make( + get: fn ($value) => User::find($value) ? User::find($value)->name : '', + ); + } +} diff --git a/resources/views/backend/sidebar.blade.php b/resources/views/backend/sidebar.blade.php index 9e091df..48bb090 100644 --- a/resources/views/backend/sidebar.blade.php +++ b/resources/views/backend/sidebar.blade.php @@ -284,6 +284,9 @@ {{LMS::createMenuLink("Followups",route('followups.index'))}} {{LMS::createMenuLink("Most Asked Questions",route('faqs.index'))}} {{LMS::createMenuLink("Inquiries",route('contactus.index'))}} + {{LMS::createMenuLink("Testimonials",route('testimonials.index'))}} + {{LMS::createMenuLink("Manage Logos",route('logos.index'))}} + diff --git a/resources/views/crud/generated/campaignarticles/create.blade.php b/resources/views/crud/generated/campaignarticles/create.blade.php index bbda858..3b1d09c 100644 --- a/resources/views/crud/generated/campaignarticles/create.blade.php +++ b/resources/views/crud/generated/campaignarticles/create.blade.php @@ -1,61 +1,67 @@ @extends('backend.template') @section('content') - -