diff --git a/app/Http/Controllers/Admin/AboutUsController.php b/app/Http/Controllers/Admin/AboutUsController.php index 782df72..18802c9 100644 --- a/app/Http/Controllers/Admin/AboutUsController.php +++ b/app/Http/Controllers/Admin/AboutUsController.php @@ -4,30 +4,170 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use App\Models\Aboutus; +use App\Models\MainCategory; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; +use Exception; +use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Auth; + + class AboutUsController extends Controller { - public function index(){ - - return view('Admin.pages.manage_cms.manage_aboutus.manage_aboutsus'); + // public function index() + // { + // return view('Admin.pages.manage_cms.manage_aboutus.manage_aboutsus'); + // } + public function index(Request $request) + { + + + try { + $about_data = Aboutus::with('category')->get(); + // @dd($about_data); + + foreach ($about_data as $k => $val) { + $about_data[$k]['thumbnail_image'] = ListingImageUrl('about_images', $val['thumbnail_image']); + } + + return view('Admin.pages.manage_cms.manage_aboutus.manage_aboutsus', compact('about_data')); + } catch (Exception $e) { + Log::error("Manage About Page Not Load " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } } public function edit($id) { - - + + try { $edit_service = Aboutus::find($id)->toArray(); - $about_us_cat = AboutUsCategory::all()->toArray(); + $about_us_cat = MainCategory::all()->toArray(); $edit_service['thumbnail_image'] = ListingImageUrl('about_images', $edit_service['thumbnail_image']); - return view('admin.pages.manage_cms.manage_about_us_edit', compact('edit_service', 'about_us_cat')); + return view('Admin.pages.manage_cms.manage_aboutus.manage_about_us_edit', compact('edit_service', 'about_us_cat')); } catch (Exception $e) { Log::error("edit voucher Page Load Failed " . $e->getMessage()); return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } + + public function update(Request $request) + { + + + try { + DB::beginTransaction(); + $about_data = Aboutus::where('id', $request->about_id)->first(); + + if ($request->hasFile('about_image')) { + $image = $request->file('about_image'); + $normalImage = saveSingleImageWithoutCrop($image, 'about_images'); + $about_data->thumbnail_image = $normalImage; + } + + $about_data->title = $request->input('about_title'); + $about_data->description = $request->input('about_des'); + $about_data->category_xid = $request->input('category'); + + $about_data->save(); + + + DB::commit(); + + return jsonResponseWithSuccessMessage(__('success.update_data')); + } catch (Exception $e) { + DB::rollBack(); + Log::error("updateCustomerNewsArticle Services Page Load Failed " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } + } + + + public function delete_about($id) + { + + + try { + $blog = Aboutus::find($id); + + if (!$blog) { + return response()->json(['error' => 'Aboutus entry not found.'], 404); + } + + $blog->delete(); + + return response()->json(['success' => 'Aboutus entry deleted successfully.']); + } catch (\Exception $e) { + // Log the exception or handle it in a way that makes sense for your application + return response()->json(['error' => 'An error occurred while deleting the Aboutus entry.'], 500); + } + } + public function change_about_Status(Request $request) + { + + + try { + $status = Aboutus::find($request->program_id); + + if (!$status) { + return response()->json(['error' => 'Aboutus entry not found.'], 404); + } + + $status->is_active = $request->status; + $status->save(); + + return response()->json(['success' => 'Status change successfully.']); + } catch (\Exception $e) { + // Log the exception or handle it in a way that makes sense for your application + return response()->json(['error' => 'An error occurred while changing the status.'], 500); + } + } + + public function add() + { + $about_us_cat = MainCategory::all()->toArray(); + return view('Admin.pages.manage_cms.manage_aboutus.manage_about_us_add', compact('about_us_cat')); + } + + public function insert(Request $request) + { + + try { + DB::beginTransaction(); + + if (isset($request->about_image)) { + $image = $request->about_image; + $image_db = null; + } else { + $image = null; + $image_db = $request->about_image; + } + $tnormalImage = saveSingleImageWithoutCrop($image, 'about_images', $image_db); + + + $about_data = new Aboutus(); + $about_data->title = $request->input('about_title'); + $about_data->description = $request->input('about_des'); + + $about_data->thumbnail_image = $tnormalImage; + $about_data->category_xid = $request->input('category'); + $about_data->save(); + + DB::commit(); + return jsonResponseWithSuccessMessage(__('success.save_data')); + // return $voucher_data; + } catch (Exception $e) { + DB::rollBack(); + Log::error("About Store Page Load Failed " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } + } + } diff --git a/app/Http/Controllers/Admin/FaqController.php b/app/Http/Controllers/Admin/FaqController.php index ca37ce4..0fe569b 100644 --- a/app/Http/Controllers/Admin/FaqController.php +++ b/app/Http/Controllers/Admin/FaqController.php @@ -2,13 +2,71 @@ namespace App\Http\Controllers\Admin; +use App\Services\Admin\faqServices; +use App\Models\Faq; +use Illuminate\Support\Facades\Log; + use App\Http\Controllers\Controller; use Illuminate\Http\Request; class FaqController extends Controller { - public function index(){ - - return view('Admin.pages.manage_cms.manage_faq.manage_faq'); + protected $faqServices; + public function __construct(faqServices $faqServices) + { + $this->faqServices = $faqServices; + } + + public function index() + { + $data = $this->faqServices->viewfaq(); + return view('Admin.pages.manage_cms.manage_faq.manage_faq')->with($data); + } + + public function change_faqStatus(Request $request) + { + $status = Faq::find($request->program_id); + $status->is_active = $request->status; + $status->save(); + return response()->json(['success' => 'Status change successfully.']); + } + + + public function delete_faq($id) + { + $faq = Faq::find($id); + if (!$faq) { + return response()->json(['success' => false, 'status' => 404, 'message' => 'FAQ not found']); + } + + $faq->delete(); + return response()->json(['success' => true, 'status' => 200]); + } + + public function update(Request $request) + { + $faq = new Faq(); + $faq = Faq::find($request->faq_id); + $faq->question = $request->question; + $faq->answers = $request->answer; + $faq->faq_category_id = $request->faq_categ; + $faq->save(); + return response()->json(['success' => true, 'status' => 200]); + } + + public function store(Request $request) + { + try { + $faq = new Faq(); + $faq->question = $request->question; + $faq->answers = $request->answer; + $faq->faq_category_id = $request->faq_categ; + $faq->save(); + + return response()->json(['success' => true, 'status' => 200]); + } catch (\Exception $e) { + // Log the exception or handle it as needed + return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]); + } } } diff --git a/app/Http/Controllers/Admin/PrivacyPolicyController.php b/app/Http/Controllers/Admin/PrivacyPolicyController.php index ea45c9c..96565fa 100644 --- a/app/Http/Controllers/Admin/PrivacyPolicyController.php +++ b/app/Http/Controllers/Admin/PrivacyPolicyController.php @@ -4,11 +4,28 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use App\Models\PrivacyPolicy; class PrivacyPolicyController extends Controller { - public function index(){ + // public function index(){ + // return view('Admin.pages.manage_cms.manage_privacy.manage_privacy'); + // } + // public function index(){ + // $view_privacy_policy = PrivacyPolicy::get()->toArray(); + // // dd($view_privacy_policy); + // return view('Admin.pages.manage_cms.manage_privacy.manage_privacy'); + // } + + public function index(){ + $view_policy = PrivacyPolicy::get()->toArray(); + // dd($view_privacy_policy); return view('Admin.pages.manage_cms.manage_privacy.manage_privacy'); } + + public function edit($id){ + $edit_privacy_policy = PrivacyPolicy::find($id)->toArray(); + return view('Admin.pages.manage_cms.manage_privacy.manage_privacy_policy_edit', compact('edit_privacy_policy')); + } } diff --git a/app/Http/Controllers/Admin/TermsController.php b/app/Http/Controllers/Admin/TermsController.php index aed5d85..0ccd18b 100644 --- a/app/Http/Controllers/Admin/TermsController.php +++ b/app/Http/Controllers/Admin/TermsController.php @@ -1,15 +1,45 @@ toArray(); + + return view('Admin.pages.manage_cms.manage_terms.manage_terms',compact('terms_condition')); } + // public function edit($id) + // { + // $terms = Termsandconditions::find($id)->toArray(); + // return view('Admin.pages.manage_cms.manage_terms.manage_terms_edit', compact('terms')); + // } + public function edit($id) +{ + + $terms = Termsandconditions::find($id); + // dd($terms); + return view('Admin.pages.manage_cms.manage_terms.manage_terms_edit', compact('terms')); + +} + + public function update(Request $request) + { + + $validated = $request->validate([ + + 'article_des' => 'required', // Add validation for article_des + ]); + $update = Termsandconditions::find($request->custom_id); + $update->message = $request->input('article_des'); + $update->save(); + return response()->json(['success' => true, 'status' => 200]); + } } diff --git a/app/Models/Faq.php b/app/Models/Faq.php index f481246..04f5364 100644 --- a/app/Models/Faq.php +++ b/app/Models/Faq.php @@ -4,9 +4,13 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; + class Faq extends Model { + use SoftDeletes; + use HasFactory; protected $table = 'faqs'; diff --git a/app/Models/Termsandconditions.php b/app/Models/Termsandconditions.php new file mode 100644 index 0000000..ae9331a --- /dev/null +++ b/app/Models/Termsandconditions.php @@ -0,0 +1,12 @@ +get(); + return $view_service; + } catch (Exception $ex) { + Log::error($ex); + throw $ex; + } + } + + public function index_about_us() + { + try { + $view_about_us = Aboutus::get(); + return $view_about_us; + } catch (Exception $ex) { + Log::error($ex); + throw $ex; + } + } + + +} + diff --git a/app/Services/Admin/faqServices.php b/app/Services/Admin/faqServices.php new file mode 100644 index 0000000..882ac98 --- /dev/null +++ b/app/Services/Admin/faqServices.php @@ -0,0 +1,20 @@ +get(); + return $data; + } + + + +} diff --git a/app/Services/Admin/termsandconditionServices.php b/app/Services/Admin/termsandconditionServices.php new file mode 100644 index 0000000..add4c98 --- /dev/null +++ b/app/Services/Admin/termsandconditionServices.php @@ -0,0 +1,17 @@ +get(); + return $data; + } + +} + diff --git a/database/migrations/2024_05_25_084200_create_faqs_table.php b/database/migrations/2024_05_25_084200_create_faqs_table.php new file mode 100644 index 0000000..c27db88 --- /dev/null +++ b/database/migrations/2024_05_25_084200_create_faqs_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBigInteger('faq_category_id'); + $table->foreign('faq_category_id')->references('id')->on('main_category'); + $table->longText('question', 100)->nullable(); + $table->longText('answers', 100)->nullable(); + $table->enum('is_active',['0','1'])->comment('0 = Inactive, 1 = Active'); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('faqs'); + } +}; diff --git a/database/migrations/2024_05_25_152503_create_termsandconditions_table.php b/database/migrations/2024_05_25_152503_create_termsandconditions_table.php new file mode 100644 index 0000000..cd5a9c8 --- /dev/null +++ b/database/migrations/2024_05_25_152503_create_termsandconditions_table.php @@ -0,0 +1,30 @@ +id(); + $table->unsignedBigInteger('category_xid'); + $table->foreign('category_xid')->references('id')->on('main_categories'); + $table->longtext('message')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('termsandconditions'); + } +}; diff --git a/public/assets/js/admin/manage_cms/manage_aboutus/add_about_us.js b/public/assets/js/admin/manage_cms/manage_aboutus/add_about_us.js index 241abe2..de20cb4 100644 --- a/public/assets/js/admin/manage_cms/manage_aboutus/add_about_us.js +++ b/public/assets/js/admin/manage_cms/manage_aboutus/add_about_us.js @@ -62,12 +62,12 @@ $(document).on("click", "#add_about_btn", function (e) { if (result.status_code == 200) { toastr.success('About Us Data Added Successfully'); setTimeout(function() { - window.location.href = base_url + "/about_us"; + window.location.href = base_url + "/manage-about-us"; }, 2000); } else { toastr.error('Something Went Wrong'); setTimeout(function() { - window.location.href = base_url + "/about_us"; + window.location.href = base_url + "/manage-about-us"; }, 2000); } $('#add_about_btn').attr('disabled', false); diff --git a/public/assets/js/admin/manage_cms/manage_aboutus/edit_about_us.js b/public/assets/js/admin/manage_cms/manage_aboutus/edit_about_us.js index 6443c68..d1c8b84 100644 --- a/public/assets/js/admin/manage_cms/manage_aboutus/edit_about_us.js +++ b/public/assets/js/admin/manage_cms/manage_aboutus/edit_about_us.js @@ -56,12 +56,12 @@ $('#update_about_us').on("click", function (e) { if (result.status_code == 200) { toastr.success('About Us Data Updated Successfully'); setTimeout(function() { - window.location.href = base_url + "/about_us"; + window.location.href = base_url + "/manage-about-us"; }, 2000); } else { toastr.error('Something Went Wrong'); setTimeout(function() { - window.location.href = base_url + "/about_us"; + window.location.href = base_url + "/manage-about-us"; }, 2000); } $('#update_about_us').attr('disabled', false); diff --git a/public/assets/js/admin/manage_cms/manage_aboutus/main.js b/public/assets/js/admin/manage_cms/manage_aboutus/main.js index d11f02d..10fb42f 100644 --- a/public/assets/js/admin/manage_cms/manage_aboutus/main.js +++ b/public/assets/js/admin/manage_cms/manage_aboutus/main.js @@ -59,7 +59,7 @@ $(document).on("click", ".delete_about_button", function (e) { success: function (response) { console.log(response); toastr.success("About Data Successfully"); - window.location.href = base_url + "/about_us"; + window.location.href = base_url + "/manage-about-us"; } }); }); diff --git a/public/assets/js/admin/manage_cms/manage_faq/add_faq.js b/public/assets/js/admin/manage_cms/manage_faq/add_faq.js index 0c46cd0..c9b0d85 100644 --- a/public/assets/js/admin/manage_cms/manage_faq/add_faq.js +++ b/public/assets/js/admin/manage_cms/manage_faq/add_faq.js @@ -5,7 +5,7 @@ $(document).on("click", "#submit_faq", function (e) { rules: { question: { required: true, - minlength: 255 + maxlength: 255 }, answer: { required: true, @@ -17,7 +17,7 @@ $(document).on("click", "#submit_faq", function (e) { messages: { question: { required: "Please enter the question.", - minlength: "The question must be at least 255 characters long." + maxlength: "The question must be at least 255 characters long." }, answer: { required: "Please enter the answer.", @@ -61,36 +61,72 @@ $(document).on("click", "#submit_faq", function (e) { // add faq end here -//delete -$(document).ready(function () { - $('.delete-faq-btn').on('click', function (e) { - e.preventDefault(); +//delete old +// $(document).ready(function () { +// $('.delete-faq-btn').on('click', function (e) { +// e.preventDefault(); - var faqId = $(this).data('faq-id'); - if (confirm('Are you sure you want to delete this FAQ?')) { - $.ajax({ - url: url_path + '/delete_faq/' + faqId, - type: 'DELETE', - headers: { - 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') - }, - success: function (response) { - if (response.status == 200) { - toastr.success('Faq deleted successfully'); - setTimeout(function () { - window.location.href = url_path + "/faq"; - }, 1000); - } else { - toastr.error("Something went wrong"); - } - }, - error: function () { - toastr.error("Error deleting FAQ"); - } - }); +// var faqId = $(this).data('faq-id'); +// if (confirm('Are you sure you want to delete this FAQ?')) { +// $.ajax({ +// url: url_path + '/delete_faq/' + faqId, +// type: 'DELETE', +// headers: { +// 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') +// }, +// success: function (response) { +// if (response.status == 200) { +// toastr.success('Faq deleted successfully'); +// setTimeout(function () { +// window.location.href = url_path + "/faq"; +// }, 1000); +// } else { +// toastr.error("Something went wrong"); +// } +// }, +// error: function () { +// toastr.error("Error deleting FAQ"); +// } +// }); +// } +// }); +// }); + +//new delete with modal +$(document).on("click", ".delete_about", function () { + var delete_id = $(this).data('faq-id'); // Corrected this line + $('#delete_about_id').val(delete_id); +}); + +$(document).on("click", ".delete_about_button", function (e) { + e.preventDefault(); + let base_url = url_path; + var faqId = $('#delete_about_id').val(); // Ensure you're getting the correct ID + + $.ajaxSetup({ + headers: { + "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), + }, + }); + $.ajax({ + type: "DELETE", + url: base_url + "/delete_faq/" + faqId, + success: function (response) { + if(response.success) { + toastr.success("FAQ successfully deleted"); + window.location.href = base_url + "/faq"; + } else { + toastr.error(response.message); + } + }, + error: function (response) { + toastr.error("An error occurred while deleting the FAQ"); } }); }); +//end delete + + // change status $(".switch-btn").on("change", ".active_newsletter", function () { diff --git a/public/assets/js/admin/manage_cms/manage_terms_cond/manage_terms_condition.js b/public/assets/js/admin/manage_cms/manage_terms_cond/manage_terms_condition.js index f60d154..c738b02 100644 --- a/public/assets/js/admin/manage_cms/manage_terms_cond/manage_terms_condition.js +++ b/public/assets/js/admin/manage_cms/manage_terms_cond/manage_terms_condition.js @@ -1,99 +1,132 @@ -// privacy policy for cust -$('#update_terms').on("click", function (e) { - $('#terms_form').validate({ - ignore: [], - debug: false, - rules: { - article_des: { - required: true - } - }, - messages: { - article_des: { - required: "Please Enter Terms and Condition" - } - }, - submitHandler: function (form) { - let base_url = url_path; - var formData = new FormData(form); - $.ajaxSetup({ - headers: { - "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), - }, - }); +$(document).ready(function() { + var quill = new Quill('#terms-quill-edit', { + theme: 'snow' + }); + + var storedMessage = document.getElementById('stored-terms-message').value; + quill.clipboard.dangerouslyPasteHTML(storedMessage); + + $('#update_terms').on("click", function(e) { + e.preventDefault(); + $('#terms_form').validate({ + ignore: [], + debug: false, + rules: { + article_des: { + required: true, + minlength:1000, + } + }, + messages: { + article_des: { + required: "Please Enter Terms and Condition", + minlength:"Please Enter Terms and Condition" + } + }, + errorClass: 'error-message', + + submitHandler: function(form) { + // Get the HTML content from Quill editor + var article_des = quill.root.innerHTML; + + if (article_des.trim() === '
No privacy policy found.
+@endif + +