JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrcreatorId())->get(); return view('imagegallery::gallery.index', compact('imagesGalleryData')); } /** * Show the form for creating a new resource. * @return Renderable */ public function create() { $qr_code = Utility::$qr_type; return view('imagegallery::gallery.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(), [ 'gallery_name' => 'required|string|max:255', 'theme' => 'required', ] ); $slug = Utility::createSlug('image_gallery_qrs', $request->gallery_name); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $imageGalleryData = ImageGalleryQr::create([ 'name' => $request->gallery_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 = 'Image Gallery'; $qrData->json = $qrJson; $qrData->template_id = $imageGalleryData->id; $qrData->created_by = \Auth::user()->creatorId(); $qrData->save(); return redirect()->route('imagegallery.edit', $imageGalleryData->id)->with('success', __('Image Gallery 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; $imageGalleryData = ImageGalleryQr::find($id); $qrData = QRSetting::where('template_id', $id)->where('type', 'Image Gallery')->first(); $qrJson = []; if (!empty($qrData->json)) { $qrJson = json_decode($qrData->json); } $app_url = trim(env('APP_URL'), '/'); $slugURL = $app_url . '/imagegalery-qr/' . $imageGalleryData->slug; return view('imagegallery::gallery.edit', compact('qr_code', 'imageGalleryData', 'qrData', 'qrJson', 'slugURL')); } /** * Update the specified resource in storage. * @param Request $request * @param int $id * @return Renderable */ public function update(Request $request, $id) { $imageGalleryData = ImageGalleryQr::findOrFail($id); $validator = \Validator::make( $request->all(), [ 'gallery_name' => 'required|string|max:255', 'website' => 'required|url', 'image_link' => 'required|url', ] ); $count = ImageGalleryQr::where('slug', $request->slug)->count(); if (!is_null($imageGalleryData)) { if ($count == 0) { $imageGalleryData->slug = $request->slug; } elseif ($count == 1) { if ($imageGalleryData->slug != $request->slug) { return redirect()->route('imagegallery.index')->with('error', __('Slug is already used.........!')); } } } $imageNames = []; $temp_images=explode(",",$request->gallery_images); $existing_images = $imageGalleryData->images; $imageNames = array_intersect($temp_images, explode(",",$existing_images)); $settings = Utility::getStorageSetting(); if ($settings['storage_setting'] == 'local') { $dir = 'image_gallery_module/gallery/'; } else { $dir = 'image_gallery_module/gallery/'; } // dd( $request->file('images')); $images = $request->file('images'); if (!empty($images) && is_array($images)) { foreach ($images as $key=>$image) { $settings = Utility::getStorageSetting(); $ext = $image->getClientOriginalExtension(); $imageName = 'gallery' . time() . rand() . '.' . $ext; if ($settings['storage_setting'] == 'local') { $dir = 'image_gallery_module/gallery/'; } else { $dir = 'image_gallery_module/gallery/'; } // Delete the existing QR code image file if it exists $image_path = $dir . $imageName; if (File::exists($image_path)) { File::delete($image_path); } // Upload the new QR code image file $path = Utility::multipalFileUpload($request,'images',$imageName,$dir,$key,[]); $imageNames[] = $imageName; } } $imageNamesString = implode(",",array_filter($imageNames)); $imageGalleryData->name = $request->gallery_name; $imageGalleryData->website = $request->website; $imageGalleryData->description = $request->description; $imageGalleryData->cta_btn_link = $request->image_link; $imageGalleryData->images = $imageNamesString; $imageGalleryData->save(); $tab = 2; return redirect()->back()->with('success', 'Image Gallery QR Updated Successfully')->with('tab', $tab); } /** * Remove the specified resource from storage. * @param int $id * @return Renderable */ public function destroy($id) { $imageGalleryData = ImageGalleryQr::find($id); if ($imageGalleryData) { $qrData = QRSetting::where('template_id', $id)->where('type', 'Image Gallery')->firstOrFail(); $qrData->delete(); $imageGalleryData->delete(); return redirect()->route('imagegallery.index')->with('success', __('Image Gallery QR successfully deleted.')); } else { return redirect()->route('imagegallery.index')->with('error', __('Image Gallery QR not found.')); } } public function editTheme($id, Request $request) { $count = ImageGalleryQr::where('id', $id)->where('created_by', \Auth::user()->creatorId())->count(); if ($count == 0) { return redirect()->route('imagegallery.index')->with('error', __('This image gallery 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()); } $imageGalleryData = ImageGalleryQr::where('id', $id)->first(); $imageGalleryData['color'] = $request->theme_color; $imageGalleryData['theme'] = $request->themefile; $imageGalleryData->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', 'Image Gallery')->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 = 'imggalleryqrcode' . time() . rand() . '.' . $ext; if ($settings['storage_setting'] == 'local') { $dir = 'image_gallery_module/center_qr/'; } else { $dir = 'image_gallery_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 = 'Image Gallery'; $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 downloadImageQR(Request $request) { $data = []; $imageGalleryData = ImageGalleryQr::findOrFail($request->image_id); $qrData = QRSetting::where('template_id', $request->image_id)->where('type', 'Image Gallery')->firstOrFail(); if ($imageGalleryData && $qrData) { $data['imageGalleryData'] = $imageGalleryData; $data['qrData'] = $qrData; $data['is_sccess'] = true; } else { $data['is_sccess'] = false; } return $data; } public function getGalleryCard($slug) { $imageGalleryData = ImageGalleryQr::where('slug', $slug)->first(); if ($imageGalleryData) { return view('imagegallery::imageGalleryTemplate.' . $imageGalleryData->theme . '.index', compact('imageGalleryData')); } else { abort(404); } } public function duplicateImageGallery($id) { $imageGalleryData = ImageGalleryQr::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); if (!is_null($imageGalleryData)) { $newGalleryData = new ImageGalleryQr(); $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'], 'filesystems.disks.wasabi.bucket' => $settings['wasabi_bucket'], 'filesystems.disks.wasabi.endpoint' => $settings['wasabi_root'], ]); } 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'], 'filesystems.disks.s3.bucket' => $settings['s3_bucket'], ]); } $newGalleryImages = []; $galleryImageFilenames=explode(',',$imageGalleryData->images); if($imageGalleryData->images) { foreach ($galleryImageFilenames as $filename) { // Generate a new unique filename $newGalleryImage = 'gallery' . uniqid() . '.' . pathinfo($filename, PATHINFO_EXTENSION); // Check if the original profile image exists if (Storage::disk($settings['storage_setting'])->exists('image_gallery_module/gallery/' . $filename)) { // Copy the profile image to the new location with the new filename Storage::disk($settings['storage_setting'])->copy('image_gallery_module/gallery/' . $filename, 'image_gallery_module/gallery/' . $newGalleryImage); // Add the new image filename to the array $newGalleryImages[] = $newGalleryImage; } } $newGalleryData->images = implode(',', $newGalleryImages); } $newGalleryData->name = $imageGalleryData->name . '_copy'; $newGalleryData->website = $imageGalleryData->website; $newGalleryData->slug = $imageGalleryData->slug . '_copy'; $newGalleryData->color = $imageGalleryData->color; $newGalleryData->description = $imageGalleryData->description; $newGalleryData->cta_btn_link = $imageGalleryData->cta_btn_link; $newGalleryData->theme = $imageGalleryData->theme; $newGalleryData->created_by = \Auth::user()->creatorId(); $newGalleryData->save(); $qrData = QRSetting::where('template_id', $id)->where('type', 'Image Gallery')->first(); $oldQRJson = json_decode($qrData->json); $newqrImage = 'new_imggalleryqrcode' . uniqid() . '.' . pathinfo($oldQRJson->image, PATHINFO_EXTENSION); $newqrImageName = ''; if ($oldQRJson->image !== null && $oldQRJson->image !== "") { $galleryQRImageContent = Storage::disk($settings['storage_setting'])->get('image_gallery_module/center_qr/' . $oldQRJson->image); if ($galleryQRImageContent !== null) { $newQRImagePath = 'image_gallery_module/center_qr/' . $newqrImage; Storage::disk($settings['storage_setting'])->put($newQRImagePath, Storage::disk($settings['storage_setting'])->get('image_gallery_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 = $newGalleryData->id; $newQRSetting->created_by = \Auth::user()->creatorId(); $newQRSetting->save(); return redirect()->back()->with('success', __('Image Gallery QR successfully duplicated.')); } } }