JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrcreatorId())->get(); return view('appdownload::apps.index', compact('appData')); } /** * Show the form for creating a new resource. * @return Renderable */ public function create() { $qr_code = Utility::$qr_type; return view('appdownload::apps.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(), [ 'app_name' => 'required|string|max:255', 'theme' => 'required', ] ); $slug = Utility::createSlug('app_download_qrs', $request->app_name); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $appData = AppDownloadQr::create([ 'name' => $request->app_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 = 'App Download'; $qrData->json = $qrJson; $qrData->template_id = $appData->id; $qrData->created_by = \Auth::user()->creatorId(); $qrData->save(); return redirect()->route('apps.edit', $appData->id)->with('success', __('App Download 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; $appData = AppDownloadQr::find($id); $qrData = QRSetting::where('template_id', $id)->where('type', 'App Download')->first(); $qrJson = []; if (!empty($qrData->json)) { $qrJson = json_decode($qrData->json); } $app_url = trim(env('APP_URL'), '/'); $slugURL = $app_url . '/app-download-qr/' . $appData->slug; return view('appdownload::apps.edit', compact('qr_code', 'appData', 'qrData', 'qrJson', 'slugURL')); } /** * Update the specified resource in storage. * @param Request $request * @param int $id * @return Renderable */ public function update(Request $request, $id) { $appData = AppDownloadQr::findOrFail($id); $validator = \Validator::make( $request->all(), [ 'app_name' => 'required|string|max:255', 'playstore_id' => 'required|url', 'appstore_id' => 'required|url', ] ); $count = AppDownloadQr::where('slug', $request->slug)->count(); if (!is_null($appData)) { if ($count == 0) { $appData->slug = $request->slug; } elseif ($count == 1) { if ($appData->slug != $request->slug) { return redirect()->route('apps.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 = 'appprofile' . time() . rand() . '.' . $ext; if ($settings['storage_setting'] == 'local') { $dir = 'app_download_module/profile/'; } else { $dir = 'app_download_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; } $appData->profile = !is_null($profileImage) ? $profileImage : $appData->profile; $appData->name = $request->app_name; $appData->developer_name = $request->developer_name; $appData->headline = $request->headline; $appData->description = $request->description; $appData->read_more_link = $request->read_more_link; $appData->website = $request->website; $appData->playstore_id = $request->playstore_id; $appData->appstore_id = $request->appstore_id; $appData->variant = !is_null($request->variant) ? $request->variant : 1;; $appData->save(); $tab = 2; return redirect()->back()->with('success', 'App Download QR Updated Successfully')->with('tab', $tab); } /** * Remove the specified resource from storage. * @param int $id * @return Renderable */ public function destroy($id) { $appData = AppDownloadQr::find($id); if ($appData) { $qrData = QRSetting::where('template_id', $id)->where('type', 'App Download')->firstOrFail(); $qrData->delete(); $appData->delete(); return redirect()->route('apps.index')->with('success', __('App Download QR successfully deleted.')); } else { return redirect()->route('apps.index')->with('error', __('App Download QR not found.')); } } public function editTheme($id, Request $request) { $count = AppDownloadQr::where('id', $id)->where('created_by', \Auth::user()->creatorId())->count(); if ($count == 0) { return redirect()->route('apps.index')->with('error', __('This app 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()); } $appData = AppDownloadQr::where('id', $id)->first(); $appData['color'] = $request->theme_color; $appData['theme'] = $request->themefile; $appData->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', 'App Download')->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 = 'appqrcode' . time() . rand() . '.' . $ext; if ($settings['storage_setting'] == 'local') { $dir = 'app_download_module/center_qr/'; } else { $dir = 'app_download_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 = 'App Download'; $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 downloadAppsQR(Request $request) { $data = []; $appData = AppDownloadQr::findOrFail($request->app_id); $qrData = QRSetting::where('template_id', $request->app_id)->where('type', 'App Download')->firstOrFail(); if ($appData && $qrData) { $data['appData'] = $appData; $data['qrData'] = $qrData; $data['is_sccess'] = true; } else { $data['is_sccess'] = false; } return $data; } public function duplicateApps($id) { $appData = AppDownloadQr::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); if (!is_null($appData)) { $newAppData = new AppDownloadQr(); $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'], ]); } $newappProfile = 'appprofile' . time() . rand() . '.' . pathinfo($appData->profile, PATHINFO_EXTENSION); if ($appData->profile !== null) { $imageName = $appData->profile; if (preg_match('/^appprofile\d+(\.\w+)?$/', $imageName)) { $profileContent = Storage::disk($settings['storage_setting'])->get('app_download_module/profile/' . $appData->profile); if ($profileContent !== false) { $newProfilePath = 'app_download_module/profile/' . $newappProfile; Storage::disk($settings['storage_setting'])->put($newProfilePath, Storage::disk($settings['storage_setting'])->get('app_download_module/profile/' . $appData->profile)); $newAppData->profile = $newappProfile; } } else { $newAppData->profile = $appData->profile_image; } } $newAppData->name = $appData->name . '_copy'; $newAppData->slug = $appData->slug . '_copy'; $newAppData->color = $appData->color; $newAppData->theme = $appData->theme; $newAppData->headline = $appData->headline; $newAppData->developer_name = $appData->developer_name; $newAppData->description = $appData->description; $newAppData->read_more_link = $appData->read_more_link; $newAppData->website = $appData->website; $newAppData->playstore_id = $appData->playstore_id; $newAppData->appstore_id = $appData->appstore_id; $newAppData->variant = $appData->variant; $newAppData->created_by = \Auth::user()->creatorId(); $newAppData->save(); $qrData = QRSetting::where('template_id', $id)->where('type', 'App Download')->first(); $oldQRJson = json_decode($qrData->json); $newqrImage = 'new_appqrcode' . uniqid() . '.' . pathinfo($oldQRJson->image, PATHINFO_EXTENSION); $newqrImageName = ''; if ($oldQRJson->image !== null && $oldQRJson->image !== "") { $appQRImageContent = Storage::disk($settings['storage_setting'])->get('app_download_module/center_qr/' . $oldQRJson->image); if ($appQRImageContent !== null) { $newQRImagePath = 'app_download_module/center_qr/' . $newqrImage; Storage::disk($settings['storage_setting'])->put($newQRImagePath, Storage::disk($settings['storage_setting'])->get('app_download_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 = $newAppData->id; $newQRSetting->created_by = \Auth::user()->creatorId(); $newQRSetting->save(); return redirect()->back()->with('success', __('App Download QR successfully duplicated.')); } } public function getAppsCard($slug) { $appData = AppDownloadQr::where('slug', $slug)->first(); if ($appData) { return view('appdownload::appsTemplate.' . $appData->theme . '.index', compact('appData')); } else { abort(404); } } }