JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrcreatorId())->get(); return view('google::google.index', compact('googleDetail')); } /** * Show the form for creating a new resource. * @return Renderable */ public function create() { $qr_code = Utility::$qr_type; return view('google::google.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(), [ 'google_name' => 'required|string|max:255', 'theme' => 'required', ] ); $slug = Utility::createSlug('google_qrs', $request->google_name); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $googleData = GoogleQr::create([ 'name' => $request->google_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 = 'Google'; $qrData->json = $qrJson; $qrData->template_id = $googleData->id; $qrData->created_by = \Auth::user()->creatorId(); $qrData->save(); return redirect()->route('google.edit', $googleData->id)->with('success', __('Google 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; $googleData = GoogleQr::find($id); $qrData = QRSetting::where('template_id', $id)->where('type', 'Google')->first(); $qrJson = []; if (!empty($qrData->json)) { $qrJson = json_decode($qrData->json); } $app_url = trim(env('APP_URL'), '/'); $slugURL = $app_url . '/google-qr/' . $googleData->slug; return view('google::google.edit', compact('qr_code', 'googleData', 'qrData', 'qrJson', 'slugURL')); } /** * Update the specified resource in storage. * @param Request $request * @param int $id * @return Renderable */ public function update(Request $request, $id) { $googleData = GoogleQr::findOrFail($id); $validator = \Validator::make( $request->all(), [ 'google_name' => 'required|string|max:255', 'google_link' => 'required', ] ); $count = GoogleQr::where('slug', $request->slug)->count(); if (!is_null($googleData)) { if ($count == 0) { $googleData->slug = $request->slug; } elseif ($count == 1) { if ($googleData->slug != $request->slug) { return redirect()->route('google.index')->with('error', __('Slug is already used.........!')); } } } if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } // if (strpos($request->form_link, 'https://docs.google.com/forms/d/e/') === false) { // $tab=2; // return redirect()->back()->with('error', 'Please enter a valid Google Form URL.')->with('tab', $tab); // } $googleData->name = $request->google_name; $googleData->google_link = $request->google_link; $googleData->save(); $tab = 2; return redirect()->back()->with('success', 'Google Qr Updated Successfully')->with('tab', $tab); } /** * Remove the specified resource from storage. * @param int $id * @return Renderable */ public function destroy($id) { $googleData = GoogleQr::find($id); if ($googleData) { $qrData = QRSetting::where('template_id', $id)->where('type', 'Google')->firstOrFail(); $qrData->delete(); $googleData->delete(); return redirect()->route('google.index')->with('success', __('Google QR successfully deleted.')); } else { return redirect()->route('google.index')->with('error', __('Google QR not found.')); } } public function editTheme($id, Request $request) { $count = GoogleQr::where('id', $id)->where('created_by', \Auth::user()->creatorId())->count(); if ($count == 0) { return redirect()->route('google.index')->with('error', __('This google qr 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()); } $googleData = GoogleQr::where('id', $id)->first(); $googleData['color'] = $request->theme_color; $googleData['theme'] = $request->themefile; $googleData->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', 'Google')->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 = 'googleqrcode' . time() . rand() . '.' . $ext; if ($settings['storage_setting'] == 'local') { $dir = 'google_module/center_qr/'; } else { $dir = 'google_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 = 'Google'; $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 downloadGoogleQR(Request $request) { $data = []; $googleData = GoogleQr::findOrFail($request->google_id); $qrData = QRSetting::where('template_id', $request->google_id)->where('type', 'Google')->firstOrFail(); if ($googleData && $qrData) { $data['googleData'] = $googleData; $data['qrData'] = $qrData; $data['is_sccess'] = true; } else { $data['is_sccess'] = false; } return $data; } public function duplicateGoogle($id) { $googleData = GoogleQr::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); if (!is_null($googleData)) { $newGoogleData = new GoogleQr(); $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'], ]); } $newGoogleData->name = $googleData->name . '_copy'; $newGoogleData->slug = $googleData->slug . '_copy'; $newGoogleData->google_link = $googleData->google_link; $newGoogleData->color = $googleData->color; $newGoogleData->theme = $googleData->theme; $newGoogleData->created_by = \Auth::user()->creatorId(); $newGoogleData->save(); $qrData = QRSetting::where('template_id', $id)->where('type', 'Google')->first(); $oldQRJson = json_decode($qrData->json); $newqrImage = 'new_googleqrcode' . uniqid() . '.' . pathinfo($oldQRJson->image, PATHINFO_EXTENSION); $newqrImageName = ''; if ($oldQRJson->image !== null && $oldQRJson->image !== "") { $formQRImageContent = Storage::disk($settings['storage_setting'])->get('google_module/center_qr/' . $oldQRJson->image); if ($formQRImageContent !== null) { $newQRImagePath = 'google_module/center_qr/' . $newqrImage; Storage::disk($settings['storage_setting'])->put($newQRImagePath, Storage::disk($settings['storage_setting'])->get('google_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 = $newGoogleData->id; $newQRSetting->created_by = \Auth::user()->creatorId(); $newQRSetting->save(); return redirect()->back()->with('success', __('Google QR successfully duplicated.')); } } public function getGoogleCard($slug) { $googleData = GoogleQr::where('slug', $slug)->first(); if ($googleData) { return view('google::googleTemplate.' . $googleData->theme . '.index', compact('googleData')); } else { abort(404); } } }