Viewing file: TemplateController.php (20.67 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller; use App\Models\Settings; use App\Models\Template; use Illuminate\Http\Request; use Illuminate\Support\Facades\File;
class TemplateController extends Controller { public function index(){ return view('admin.template.index'); } public function store(Request $request){ if (env("APP_DEMO")){ return redirect()->back()->withErrors(['msg' => trans('admin.app_demo_message')]); } $data_template = auth()->user()->settings()->where('name','template')->first(); if ($data_template && isset($data_template->value)){ $template = json_decode($data_template->value); }
if(isset($template) && isset($template->banner_sec_bg_image_file_name)){ $request['banner_sec_bg_image_file_name'] = $template->banner_sec_bg_image_file_name; } if ($request->hasFile('banner_section_bg_image')) { $file = $request->file('banner_section_bg_image'); $bannerImage = time() . '_1' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $bannerImage); $request['banner_sec_bg_image_file_name'] = $bannerImage; }
if(isset($template) && isset($template->first_img_file_name)){ $request['first_img_file_name'] = $template->first_img_file_name; }
if ($request->hasFile('first_img')) { $file = $request->file('first_img'); $imageOneName = time(). '_2'. '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageOneName); $request['first_img_file_name'] = $imageOneName; } if(isset($template) && isset($template->footer_sec_img_one_file)){ $request['footer_sec_img_one_file'] = $template->footer_sec_img_one_file; }
if ($request->hasFile('footer_sec_img_one')) { $file = $request->file('footer_sec_img_one'); $footerImageOne = time(). '4_2'. '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $footerImageOne); $request['footer_sec_img_one_file'] = $footerImageOne; } if(isset($template) && isset($template->footer_sec_img_two_file)){ $request['footer_sec_img_two_file'] = $template->footer_sec_img_two_file; }
if ($request->hasFile('footer_sec_img_two')) { $file = $request->file('footer_sec_img_two'); $footerImageTwo = time(). '4_3'. '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $footerImageTwo); $request['footer_sec_img_two_file'] = $footerImageTwo; }
if(isset($template) && isset($template->sec_img_file_name)){ $request['sec_img_file_name'] = $template->sec_img_file_name; } if ($request->hasFile('sec_img')) { $file = $request->file('sec_img'); $imageTwoName = time(). '_3' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageTwoName); $request['sec_img_file_name'] = $imageTwoName; }
if(isset($template) && Isset($template->thr_img_file_name)){ $request['thr_img_file_name'] = $template->thr_img_file_name; }
if ($request->hasFile('thr_img')) { $file = $request->file('thr_img'); $imageThreeName = time(). '_4' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageThreeName); $request['thr_img_file_name'] = $imageThreeName; }
if(isset($template) && isset($template->contact_us_bg_image_file)){ $request['contact_us_bg_image_file'] = $template->contact_us_bg_image_file; }
if ($request->hasFile('contact_us_bg_image')) { $file = $request->file('contact_us_bg_image'); $imageContactUsName = time(). '_5' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageContactUsName); $request['contact_us_bg_image_file'] = $imageContactUsName; } if(isset($template) && isset($template->faq_bg_image_file)){ $request['faq_bg_image_file'] = $template->faq_bg_image_file; }
if ($request->hasFile('faq_bg_image')) { $file = $request->file('faq_bg_image'); $faqImage = time(). '_1_25' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $faqImage); $request['faq_bg_image_file'] = $faqImage; }
if(isset($template) && isset($template->sec_seven_bg_image_file)){ $request['sec_seven_bg_image_file'] = $template->sec_seven_bg_image_file; } if(isset($template) && isset($template->section_one_bg_image_file)){ $request['section_one_bg_image_file'] = $template->section_one_bg_image_file; } if ($request->hasFile('section_one_bg_image')) { $file = $request->file('section_one_bg_image'); $imageFiveName = time(). '_6_8' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageFiveName); $request['section_one_bg_image_file'] = $imageFiveName; } ///// if(isset($template) && isset($template->section_two_bg_image_one_file)){ $request['section_two_bg_image_one_file'] = $template->section_two_bg_image_one_file; } if ($request->hasFile('section_two_bg_image_one')) { $file = $request->file('section_two_bg_image_one'); $imageFiveNameSecTwoOne = time(). 'sec_8' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageFiveNameSecTwoOne); $request['section_two_bg_image_one_file'] = $imageFiveNameSecTwoOne; }
if(isset($template) && isset($template->section_two_bg_image_two_file)){ $request['section_two_bg_image_two_file'] = $template->section_two_bg_image_two_file; } if ($request->hasFile('section_two_bg_image_two')) { $file = $request->file('section_two_bg_image_two'); $imageFiveNameSecTwoTwo = time(). 'sec_r8' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageFiveNameSecTwoTwo); $request['section_two_bg_image_two_file'] = $imageFiveNameSecTwoTwo; }
if(isset($template) && isset($template->section_two_bg_image_three_file)){ $request['section_two_bg_image_three_file'] = $template->section_two_bg_image_three_file; } if ($request->hasFile('section_two_bg_image_three')) { $file = $request->file('section_two_bg_image_three'); $imageFiveNameSecTwoThree = time(). 'sec_18' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageFiveNameSecTwoThree); $request['section_two_bg_image_three_file'] = $imageFiveNameSecTwoThree; } if(isset($template) && isset($template->section_three_bg_image_file_one)){ $request['section_three_bg_image_file_one'] = $template->section_three_bg_image_file_one; } if ($request->hasFile('section_three_bg_image_one')) { $file = $request->file('section_three_bg_image_one'); $imageSecThreeName = time(). '_61_' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageSecThreeName); $request['section_three_bg_image_file_one'] = $imageSecThreeName; } if(isset($template) && isset($template->section_three_bg_image_file_two)){ $request['section_three_bg_image_file_two'] = $template->section_three_bg_image_file_two; } if ($request->hasFile('section_three_bg_image_two')) { $file = $request->file('section_three_bg_image_two'); $imageSecThreeName = time(). '_61_' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageSecThreeName); $request['section_three_bg_image_file_two'] = $imageSecThreeName; } if(isset($template) && isset($template->section_six_customer_img_one_file)){ $request['section_six_customer_img_one_file'] = $template->section_six_customer_img_one_file; } if ($request->hasFile('section_six_customer_img_one')) { $file = $request->file('section_six_customer_img_one'); $imageSecSixName = time(). '_521_' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageSecSixName); $request['section_six_customer_img_one_file'] = $imageSecSixName; } if(isset($template) && isset($template->section_six_customer_img_two_file)){ $request['section_six_customer_img_two_file'] = $template->section_six_customer_img_two_file; } if ($request->hasFile('section_six_customer_img_two')) { $file = $request->file('section_six_customer_img_two'); $imageSecSevName = time(). '_621_' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageSecSevName); $request['section_six_customer_img_two_file'] = $imageSecSevName; } if(isset($template) && isset($template->section_six_customer_img_three_file)){ $request['section_six_customer_img_three_file'] = $template->section_six_customer_img_three_file; } if ($request->hasFile('section_six_customer_img_three')) { $file = $request->file('section_six_customer_img_three'); $imageSecEightName = time(). '_721_' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageSecEightName); $request['section_six_customer_img_three_file'] = $imageSecEightName; } if(isset($template) && isset($template->section_seven_bg_image_file)){ $request['section_seven_bg_image_file'] = $template->section_seven_bg_image_file; } if ($request->hasFile('section_seven_bg_image')) { $file = $request->file('section_seven_bg_image'); $imageSevnName = time(). '_791_' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageSevnName); $request['section_seven_bg_image_file'] = $imageSevnName; } if(isset($template) && isset($template->section_four_bg_image_file)){ $request['section_four_bg_image_file'] = $template->section_four_bg_image_file; } if ($request->hasFile('section_four_bg_image')) { $file = $request->file('section_four_bg_image'); $imageSecFourName = time(). '_6_0' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageSecFourName); $request['section_four_bg_image_file'] = $imageSecFourName; }
if(isset($template) && isset($template->video_file_name)){ $request['video_file_name'] = $template->video_file_name; } if ($request->hasFile('video_file')) { $file = $request->file('video_file'); $videoFileName = time() . '_13_' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $videoFileName); $request['video_file_name'] = $videoFileName; }
if ($request->hasFile('sec_seven_bg_image')) { $file = $request->file('sec_seven_bg_image'); $imageFiveName = time(). '_6' . '.' . $file->getClientOriginalExtension(); $file->move(public_path('/uploads'), $imageFiveName); $request['sec_seven_bg_image_file'] = $imageFiveName; } $gateWayImages=isset($data_template->value)?json_decode($data_template->value):''; $gatewayImages=[]; if (isset($gateWayImages->payment_gateway_img)) { foreach (json_decode($gateWayImages->payment_gateway_img) as $pics) { $gatewayImages[] = $pics; } } if ($request->hasfile('payment_gateways')){ foreach ($request->file('payment_gateways') as $key => $image) { $filename = time() . 'payment'.$key. '.' . $image->getClientOriginalExtension(); $image->move(public_path('/uploads'), $filename); $gatewayImages[]=$filename; } }
$request['payment_gateway_desc']=clean($request->payment_desc); $request['payment_gateway_img']=json_encode($gatewayImages);
if (isset($data_template) && $data_template->name == 'template'){ $template = Settings::where('name', 'template')->first(); $template->value = json_encode($request->only('payment_gateway_desc','payment_gateway_img','title','description','description','section_two_sub_title_one','section_two_sub_title_two','section_two_title', 'section_two_sub_title_one_two','section_two_sub_title_two_two','section_two_title_two', 'section_two_sub_title_one_three','section_two_sub_title_two_three','section_two_title_three', 'section_two_bg_image_one_file','section_two_bg_image_two_file','section_two_bg_image_three_file','banner_section_sub_title','banner_section_progress_one_des','banner_section_progress_two_des','banner_section_progress_one','banner_section_progress_two','section_one_first_title','section_one_second_title','section_one_bg_image_file', 'section_three_first_title','section_three_second_title','section_three_sub_title','section_three_progress_percentage','section_three_bg_image_file_one','section_three_bg_image_file_two','footer_sec_img_one_file','footer_sec_img_two_file','footer_link_one','footer_link_two','section_four_title','section_four_progress_one','section_four_progress_two','section_four_progress_one_des','section_four_progress_two_des','section_four_description','section_four_bg_image_file','section_five_title_one','section_five_title_two','section_five_title_three','section_five_title_four','section_five_description_one','section_five_description_two','section_five_description_three','section_five_description_four','faq_title','faq_bg_image_file','contact_us_sub_title','contact_us_title','contact_us_bg_image_file','video_file_name', 'first_title','section_six_title','section_six_description','section_six_customer_name_one','section_six_customer_name_two','section_six_customer_name_three','section_six_customer_age_one','section_six_customer_age_two','section_six_customer_age_three','section_six_customer_description_one','section_six_customer_description_two','section_six_customer_description_three','section_six_customer_img_one_file','section_six_customer_img_two_file','section_six_customer_img_three_file','section_seven_title_one','section_seven_title_two','section_seven_bg_image_file','first_description','sec_title','sec_description','thr_title','thr_description','about_us_title','about_us_description','main_title','sec_four_title','sec_four_description','sec_five_title','sec_six_title','sec_seven_title','sec_seven_description','banner_sec_bg_image_file_name','banner_section_title','banner_section_description','first_img_file_name','sec_img_file_name','thr_img_file_name','about_us_bg_image_file','sec_seven_bg_image_file', 'video_link','section_goal_title','section_goal_sub_title','social_link_skype','social_link_facebook','social_link_twitter','social_link_youtube','social_link_linkedin','social_link_pinterest')); $template->save(); }else{ $template = new Settings(); $template->name = 'template'; $template->value = json_encode($request->only('payment_gateway_desc','payment_gateway_img','title','description','description','section_two_sub_title_one','section_two_sub_title_two','section_two_title', 'section_two_sub_title_one_two','section_two_sub_title_two_two','section_two_title_two', 'section_two_sub_title_one_three','section_two_sub_title_two_three','section_two_title_three', 'section_two_bg_image_one_file','section_two_bg_image_two_file','section_two_bg_image_three_file','banner_section_sub_title','banner_section_progress_one_des','banner_section_progress_two_des','banner_section_progress_one','banner_section_progress_two','section_one_first_title','section_one_second_title','section_one_bg_image_file', 'section_three_first_title','section_three_second_title','section_three_sub_title','section_three_progress_percentage','section_three_bg_image_file_one','footer_sec_img_one_file','footer_sec_img_two_file','footer_link_one','footer_link_two','section_four_title','section_four_progress_one','section_four_progress_two','section_four_progress_one_des','section_four_progress_two_des','section_four_description','section_four_bg_image_file','section_five_title_one','section_five_title_two','section_five_title_three','section_five_title_four','section_five_description_one','section_five_description_two','section_five_description_three','section_five_description_four','faq_title','faq_bg_image_file','contact_us_sub_title','contact_us_title','contact_us_bg_image_file','video_file_name', 'first_title','section_six_title','section_six_description','section_six_customer_name_one','section_six_customer_name_two', 'section_six_customer_name_three','section_six_customer_age_one','section_six_customer_age_two','section_six_customer_age_three', 'section_six_customer_description_one','section_six_customer_description_two','section_six_customer_description_three', 'section_six_customer_img_one_file','section_six_customer_img_two_file','section_six_customer_img_three_file', 'section_seven_title_one','section_seven_title_two','section_seven_bg_image_file','first_description','sec_title', 'sec_description','thr_title','thr_description','about_us_title','about_us_description','main_title','sec_four_title', 'sec_four_description','sec_five_title','sec_six_title','sec_seven_title','sec_seven_description','banner_sec_bg_image_file_name', 'banner_section_title','banner_section_description','first_img_file_name','sec_img_file_name','thr_img_file_name', 'about_us_bg_image_file','sec_seven_bg_image_file','section_goal_title','section_goal_sub_title', 'social_link_skype','social_link_facebook','social_link_twitter','social_link_youtube','social_link_linkedin','social_link_pinterest')); $template->admin_id = auth()->user()->id; $template->save(); } cache()->flush(); return redirect()->back()->with('success','Template successfully update'); }
public function paymentPartnerImage(Request $request) { $data_template = auth()->user()->settings()->where('name','template')->first(); $images=json_decode($data_template->value); $allValues=[]; foreach ($images as $key=>$item) { $allValues[$key]=$item; } $partnerImages = $allValues['payment_gateway_img']; $pics = json_decode($partnerImages); if (($key = array_search($request->image, $pics)) !== false) { $this->instantImageDelete($pics[$key]); unset($pics[$key]); } $newPics = []; foreach ($pics as $pic) { $newPics[] = $pic; }
$allValues['payment_gateway_img']=json_encode($newPics); $data_template->value=json_encode($allValues); $data_template->save();
cache()->flush(); return response()->json(['status' => 'success', 'message' => trans('Pic successfully deleted')]); }
function instantImageDelete($pics) { if ($pics) { $fileN = public_path('/uploads') . '/' . $pics; if (File::exists($fileN)) unlink($fileN); } } public function theme(){
return view('admin.template.theme'); }
public function themeStore(Request $request){ if (env("APP_DEMO")){ return redirect()->back()->withErrors(['msg' => trans('admin.app_demo_message')]); } $requestData=[ 'type'=>$request->type, 'navbar_color'=>$request->navbar_color, 'left_sidebar'=>$request->left_sidebar, 'active_sidebar'=>$request->active_sidebar, 'collapse_sidebar'=>$request->collapse_sidebar, ]; $data = ['name' => 'theme_customize']; $setting = auth()->user()->settings()->firstOrNew($data); $setting->value = json_encode($requestData); $setting->save(); cache()->flush(); return redirect()->route('admin.theme.customize')->with('success', 'Successfully save data'); } }
|