JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrcreatorId())->get(); return view('googleform::googleform.index',compact('googleFormData')); } /** * Show the form for creating a new resource. * @return Renderable */ public function create() { $qr_code = GoogleFormQr::$qr_type; return view('googleform::googleform.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(), [ 'form_name' => 'required|string|max:255', 'theme' => 'required', ] ); $slug = Utility::createSlug('google_form_qrs', $request->form_name); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $formData = GoogleFormQr::create([ 'name' => $request->form_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 Form'; $qrData->json = $qrJson; $qrData->template_id = $formData->id; $qrData->created_by = \Auth::user()->creatorId(); $qrData->save(); return redirect()->route('googleform.edit', $formData->id)->with('success', __('Google Form 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 = GoogleFormQr::$qr_type; $formData = GoogleFormQr::find($id); $qrData = QRSetting::where('template_id', $id)->where('type', 'Google Form')->first(); $qrJson = []; if (!empty($qrData->json)) { $qrJson = json_decode($qrData->json); } $app_url = trim(env('APP_URL'), '/'); $slugURL = $app_url . '/googleform-qr/' . $formData->slug; return view('googleform::googleform.edit', compact('qr_code', 'formData', 'qrData', 'qrJson', 'slugURL')); } /** * Update the specified resource in storage. * @param Request $request * @param int $id * @return Renderable */ public function update(Request $request, $id) { $formData = GoogleFormQr::findOrFail($id); $validator = \Validator::make( $request->all(), [ 'form_name' => 'required|string|max:255', 'form_link' => 'required', ] ); $count = GoogleFormQr::where('slug', $request->slug)->count(); if (!is_null($formData)) { if ($count == 0) { $formData->slug = $request->slug; } elseif ($count == 1) { if ($formData->slug != $request->slug) { return redirect()->route('googleform.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); } $formData->name = $request->form_name; $formData->form_link = $request->form_link; $formData->save(); $tab = 2; return redirect()->back()->with('success', 'Google Form Qr Updated Successfully')->with('tab', $tab); } /** * Remove the specified resource from storage. * @param int $id * @return Renderable */ public function destroy($id) { $formData = GoogleFormQr::find($id); if ($formData) { $qrData = QRSetting::where('template_id', $id)->where('type', 'Google Form')->firstOrFail(); $qrData->delete(); $formData->delete(); return redirect()->route('googleform.index')->with('success', __('Google Form QR successfully deleted.')); } else { return redirect()->route('googleform.index')->with('error', __('Google Form QR not found.')); } } public function editTheme($id, Request $request) { $count = GoogleFormQr::where('id', $id)->where('created_by', \Auth::user()->creatorId())->count(); if ($count == 0) { return redirect()->route('googleform.index')->with('error', __('This google form 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()); } $formData = GoogleFormQr::where('id', $id)->first(); $formData['color'] = $request->theme_color; $formData['theme'] = $request->themefile; $formData->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 Form')->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 = 'formqrcode' . time() . rand() . '.' . $ext; if ($settings['storage_setting'] == 'local') { $dir = 'google_form_module/center_qr/'; } else { $dir = 'google_form_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 Form'; $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 downloadFormQR(Request $request) { $data = []; $formData = GoogleFormQr::findOrFail($request->form_id); $qrData = QRSetting::where('template_id', $request->form_id)->where('type', 'Google Form')->firstOrFail(); if ($formData && $qrData) { $data['formData'] = $formData; $data['qrData'] = $qrData; $data['is_sccess'] = true; } else { $data['is_sccess'] = false; } return $data; } public function duplicateForm($id) { $formData = GoogleFormQr::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); if (!is_null($formData)) { $newformData = new GoogleFormQr(); $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'], ]); } $newformData->name =$formData->name.'_copy'; $newformData->slug = $formData->slug . '_copy'; $newformData->form_link =$formData->form_link; $newformData->color = $formData->color; $newformData->theme = $formData->theme; $newformData->created_by = \Auth::user()->creatorId(); $newformData->save(); $qrData = QRSetting::where('template_id', $id)->where('type', 'Google Form')->first(); $oldQRJson = json_decode($qrData->json); $newqrImage = 'new_formqrcode' . uniqid() . '.' . pathinfo($oldQRJson->image, PATHINFO_EXTENSION); $newqrImageName = ''; if ($oldQRJson->image !== null && $oldQRJson->image !== "") { $formQRImageContent = Storage::disk($settings['storage_setting'])->get('google_form_module/center_qr/' . $oldQRJson->image); if ($formQRImageContent !== null) { $newQRImagePath = 'google_form_module/center_qr/' . $newqrImage; Storage::disk($settings['storage_setting'])->put($newQRImagePath, Storage::disk($settings['storage_setting'])->get('google_form_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 = $newformData->id; $newQRSetting->created_by = \Auth::user()->creatorId(); $newQRSetting->save(); return redirect()->back()->with('success', __('Google Form QR successfully duplicated.')); } } public function getGoogleFormCard($slug) { $formData = GoogleFormQr::where('slug', $slug)->first(); if ($formData) { return view('googleform::googleformTemplate.' . $formData->theme . '.index', compact('formData')); } else { abort(404); } } }