JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrcreatorId())->get(); return view('socialmedia::social.index',compact('socialData')); } /** * Show the form for creating a new resource. * @return Renderable */ public function create() { $qr_code = Utility::$qr_type; return view('socialmedia::social.create',compact('qr_code')); } /** * Store a newly created resource in storage. * @param Request $request * @return Renderable */ public function store(Request $request) { $validator = \Validator::make( $request->all(), [ 'social_name' => 'required|string|max:255', 'theme' => 'required', ] ); $slug = Utility::createSlug('social_media_qrs', $request->social_name); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $socialData = SocialMediaQr::create([ 'name' => $request->social_name, 'slug' => $slug, 'theme' => $request->theme, 'color' => !empty($request->theme_color) ? $request->theme_color : 'color1-' . $request->theme, 'created_by' => \Auth::user()->creatorId() ]); $qrDetail = [ "foreground_color" => '#000000', "background_color" => '#ffffff', "radius" => 26, "qr_text" => '', "qr_text_color" => '#f50a0a', "image" => '', "size" => 9, "qr_type" => 0, ]; $qrJson = json_encode($qrDetail); $qrData = new QRSetting(); $qrData->type = 'Social Media'; $qrData->json = $qrJson; $qrData->template_id = $socialData->id; $qrData->created_by = \Auth::user()->creatorId(); $qrData->save(); return redirect()->route('social.edit', $socialData->id)->with('success', __('Social Media QR Created Successfully')); } /** * Show the specified resource. * @param int $id * @return Renderable */ public function show($id) { return redirect()->back(); } /** * Show the form for editing the specified resource. * @param int $id * @return Renderable */ public function edit($id) { $qr_code = Utility::$qr_type; $socialData = SocialMediaQr::find($id); $social_content = []; if (!empty($socialData->content)) { $social_content = json_decode($socialData->content); } $qrData = QRSetting::where('template_id', $id)->where('type', 'Social Media')->first(); $qrJson = []; if (!empty($qrData->json)) { $qrJson = json_decode($qrData->json); } $app_url = trim(env('APP_URL'), '/'); $slugURL = $app_url . '/socialmedia-qr/' . $socialData->slug; $businessfields = Utility::getFields(); return view('socialmedia::social.edit', compact('qr_code', 'socialData', 'qrData', 'qrJson', 'slugURL','social_content','businessfields')); } /** * Update the specified resource in storage. * @param Request $request * @param int $id * @return Renderable */ public function update(Request $request, $id) { $socialData = SocialMediaQr::findOrFail($id); $validator = \Validator::make( $request->all(), [ 'social_name' => 'required|string|max:255', ] ); $count = SocialMediaQr::where('slug', $request->slug)->count(); if (!is_null($socialData)) { if ($count == 0) { $socialData->slug = $request->slug; } elseif ($count == 1) { if ($socialData->slug != $request->slug) { return redirect()->route('social.index')->with('error', __('Slug is already used.........!')); } } } if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if (!is_null($request->file('profile_image'))) { $settings = Utility::getStorageSetting(); $profile = $request->file('profile_image'); $ext = $profile->getClientOriginalExtension(); $profileImage = 'socialprofile' . time() . rand() . '.' . $ext; if ($settings['storage_setting'] == 'local') { $dir = 'social_media_module/profile/'; } else { $dir = 'social_media_module/profile/'; } // Delete the existing QR code image file if it exists $image_path = $dir . $profileImage; if (File::exists($image_path)) { File::delete($image_path); } // Upload the new QR code image file $path = Utility::upload_file($request, 'profile_image', $profileImage, $dir, []); } else { $profileImage = $request->selected_profile_image; } $sociallinks_content = json_encode($request->socials); $socialData->profile = !is_null($profileImage) ? $profileImage : $socialData->profile; $socialData->name = $request->social_name; $socialData->headline = $request->headline; $socialData->description = $request->description; $socialData->content = $sociallinks_content; $socialData->save(); $tab = 2; return redirect()->back()->with('success', 'Social Media QR Updated Successfully')->with('tab', $tab); } /** * Remove the specified resource from storage. * @param int $id * @return Renderable */ public function destroy($id) { $socialData = SocialMediaQr::find($id); if ($socialData) { $qrData = QRSetting::where('template_id', $id)->where('type', 'Social Media')->firstOrFail(); $qrData->delete(); $socialData->delete(); return redirect()->route('social.index')->with('success', __('Social Media QR successfully deleted.')); } else { return redirect()->route('social.index')->with('error', __('Social Media QR not found.')); } } public function editTheme($id, Request $request) { $count = SocialMediaQr::where('id', $id)->where('created_by', \Auth::user()->creatorId())->count(); if ($count == 0) { return redirect()->route('social.index')->with('error', __('This social media is not your')); } $validator = \Validator::make( $request->all(), [ 'theme_color' => 'required', 'themefile' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $socialData = SocialMediaQr::where('id', $id)->first(); $socialData['color'] = $request->theme_color; $socialData['theme'] = $request->themefile; $socialData->save(); $tab = 1; return redirect()->back()->with('success', __('Theme Successfully Updated.'))->with('tab', $tab); } public function saveCustomQrsetting(Request $request, $id) { $qrData = QRSetting::where('template_id', $id)->where('type', 'Social Media')->first(); $qrJsonDetail = json_decode($qrData->json); $fileNameQR = null; if (!is_null($request->file('image'))) { $settings = Utility::getStorageSetting(); $qrcode = $request->file('image'); $ext = $qrcode->getClientOriginalExtension(); $fileNameQR = 'socialqrcode' . time() . rand() . '.' . $ext; if ($settings['storage_setting'] == 'local') { $dir = 'social_media_module/center_qr/'; } else { $dir = 'social_media_module/center_qr/'; } // Delete the existing QR code image file if it exists $image_path = $dir . $fileNameQR; if (File::exists($image_path)) { File::delete($image_path); } // Upload the new QR code image file $path = Utility::upload_file($request, 'image', $fileNameQR, $dir, []); } if (!isset($fileNameQR)) { $fileNameQR = isset($qrJsonDetail->image) ? $qrJsonDetail->image : null; } $qrDetail = [ "foreground_color" => $request->foreground_color, "background_color" => $request->background_color, "radius" => $request->radius, "qr_text" => $request->qr_text, "qr_text_color" => $request->qr_text_color, "image" => $fileNameQR, "size" => $request->size, "qr_type" => isset($request->qr_type) ? $request->qr_type : 0, ]; $qrJson = json_encode($qrDetail); if (empty($qrData)) { $qrData = new QRSetting(); } $qrData->type = 'Social Media'; $qrData->json = $qrJson; $qrData->template_id = $id; $qrData->created_by = \Auth::user()->creatorId(); $qrData->save(); $tab = 3; return redirect()->back()->with('success', 'QrCode generated successfully')->with('tab', $tab); } public function downloadSocialQR(Request $request) { $data = []; $socialData = SocialMediaQr::findOrFail($request->social_id); $qrData = QRSetting::where('template_id', $request->social_id)->where('type', 'Social Media')->firstOrFail(); if ($socialData && $qrData) { $data['socialData'] = $socialData; $data['qrData'] = $qrData; $data['is_sccess'] = true; } else { $data['is_sccess'] = false; } return $data; } public function duplicateSocial($id) { $socialData = SocialMediaQr::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); if (!is_null($socialData)) { $newSocialData = new SocialMediaQr(); $settings = Utility::getStorageSetting(); if ($settings['storage_setting'] == 'wasabi') { config([ 'filesystems.disks.wasabi.key' => $settings['wasabi_key'], 'filesystems.disks.wasabi.secret' => $settings['wasabi_secret'], 'filesystems.disks.wasabi.region' => $settings['wasabi_region'], // Ensure this value is set in your configuration 'filesystems.disks.wasabi.bucket' => $settings['wasabi_bucket'], 'filesystems.disks.wasabi.endpoint' => $settings['wasabi_root'], // Ensure this value is set in your configuration ]); } if ($settings['storage_setting'] == 's3') { config([ 'filesystems.disks.s3.key' => $settings['s3_key'], 'filesystems.disks.s3.secret' => $settings['s3_secret'], 'filesystems.disks.s3.region' => $settings['s3_region'], // Ensure this value is set in your configuration 'filesystems.disks.s3.bucket' => $settings['s3_bucket'], ]); } $newProfile = 'socialprofile' . time() . rand() . '.' . pathinfo($socialData->profile, PATHINFO_EXTENSION); if ($socialData->profile !== null) { $imageName = $socialData->profile; if (preg_match('/^socialprofile\d+(\.\w+)?$/', $imageName)) { $profileContent = Storage::disk($settings['storage_setting'])->get('social_media_module/profile/' . $socialData->profile); if ($profileContent !== false) { $newProfilePath = 'social_media_module/profile/' . $newProfile; Storage::disk($settings['storage_setting'])->put($newProfilePath, Storage::disk($settings['storage_setting'])->get('social_media_module/profile/' . $socialData->profile)); $newSocialData->profile = $newProfile; } } else { $newSocialData->profile = $socialData->profile_image; } } $newSocialData->name = $socialData->name . '_copy'; $newSocialData->slug = $socialData->slug . '_copy'; $newSocialData->color = $socialData->color; $newSocialData->theme = $socialData->theme; $newSocialData->headline = $socialData->headline; $newSocialData->description = $socialData->description; $newSocialData->content = $socialData->content; $newSocialData->created_by = \Auth::user()->creatorId(); $newSocialData->save(); $qrData = QRSetting::where('template_id', $id)->where('type', 'Social Media')->first(); $oldQRJson = json_decode($qrData->json); $newqrImage = 'new_appqrcode' . uniqid() . '.' . pathinfo($oldQRJson->image, PATHINFO_EXTENSION); $newqrImageName = ''; if ($oldQRJson->image !== null && $oldQRJson->image !== "") { $socialQRImageContent = Storage::disk($settings['storage_setting'])->get('social_media_module/center_qr/' . $oldQRJson->image); if ($socialQRImageContent !== null) { $newQRImagePath = 'social_media_module/center_qr/' . $newqrImage; Storage::disk($settings['storage_setting'])->put($newQRImagePath, Storage::disk($settings['storage_setting'])->get('social_media_module/center_qr/' . $oldQRJson->image)); $newqrImageName = $newqrImage; } } $qrDetail = [ "foreground_color" => $oldQRJson->foreground_color, "background_color" => $oldQRJson->background_color, "radius" => $oldQRJson->radius, "qr_text" => $oldQRJson->qr_text, "qr_text_color" => $oldQRJson->qr_text_color, "image" => $newqrImageName, "size" => $oldQRJson->size, "qr_type" => $oldQRJson->qr_type, ]; $newQRSetting = new QRSetting(); $newQRSetting->type = $qrData->type; $newQRSetting->json = json_encode($qrDetail); $newQRSetting->template_id = $newSocialData->id; $newQRSetting->created_by = \Auth::user()->creatorId(); $newQRSetting->save(); return redirect()->back()->with('success', __('Social Media QR successfully duplicated.')); } } public function getSocialCard($slug) { $socialData = SocialMediaQr::where('slug', $slug)->first(); $social_content = []; if (!empty($socialData->content)) { $social_content = json_decode($socialData->content); } if ($socialData) { return view('socialmedia::socialTemplate.' . $socialData->theme . '.index', compact('socialData','social_content')); } else { abort(404); } } }