diff --git a/src/Config/system.php b/src/Config/system.php index 9b05db4b3..62adc76cd 100644 --- a/src/Config/system.php +++ b/src/Config/system.php @@ -15,6 +15,10 @@ 'sort' => 1, 'fields' => [ [ + 'name' => 'status', + 'title' => 'pwa::app.admin.system.status', + 'type' => 'boolean' + ], [ 'name' => 'name', 'title' => 'pwa::app.admin.system.name', 'type' => 'text', diff --git a/src/Helpers/AdminHelper.php b/src/Helpers/AdminHelper.php index 97909a3f6..238d88296 100644 --- a/src/Helpers/AdminHelper.php +++ b/src/Helpers/AdminHelper.php @@ -32,15 +32,17 @@ public function __construct( */ public function storeCategoryIcon($category) { - $data = request()->all(); + if ( core()->getConfigData('pwa.settings.general.status') ) { + $data = request()->all(); - if (! $category instanceof \Webkul\Category\Contracts\Category) { - $category = $this->categoryRepository->findOrFail($category); - } - - $category->category_product_in_pwa = ($data['add_in_pwa'] ?? 0) == "1" ? 1 : 0; - $category->save(); + if (! $category instanceof \Webkul\Category\Contracts\Category) { + $category = $this->categoryRepository->findOrFail($category); + } + $category->category_product_in_pwa = ($data['add_in_pwa'] ?? 0) == "1" ? 1 : 0; + $category->save(); + } + return $category; } } \ No newline at end of file diff --git a/src/Http/Controllers/SinglePageController.php b/src/Http/Controllers/SinglePageController.php index 626114497..c323fcfe0 100644 --- a/src/Http/Controllers/SinglePageController.php +++ b/src/Http/Controllers/SinglePageController.php @@ -38,6 +38,12 @@ public function home() */ public function index() { + if (! core()->getConfigData('pwa.settings.general.status') ) { + session()->flash('warning', trans('pwa::app.shop.home.enable-pwa-status')); + + return redirect()->route('shop.home.index'); + } + $parsedUrl = parse_url(config('app.url')); $urlPath = isset($parsedUrl['path']) ? $parsedUrl['path'] : ''; diff --git a/src/Resources/lang/en/app.php b/src/Resources/lang/en/app.php index 67a702ba9..f15568279 100644 --- a/src/Resources/lang/en/app.php +++ b/src/Resources/lang/en/app.php @@ -4,6 +4,7 @@ 'admin' => [ 'system' => [ 'pwa' => 'PWA', + 'status' => 'Status', 'btn-save' => 'Save', 'name' => 'Name', 'topic' => 'Topic', @@ -64,5 +65,11 @@ 'target-url' => 'Target URL', 'description' => 'Description', ] + ], + + 'shop' => [ + 'home' => [ + 'enable-pwa-status' => 'Warning: Please enable pwa extension status from the configuration.', + ] ] ]; \ No newline at end of file