Skip to content

Commit 36d3501

Browse files
committed
added safety remove for category and group
1 parent b0cb0d1 commit 36d3501

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

app/Http/Controllers/Admin/CategoryController.php

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use App\Http\Requests\CategorySaveRequest;
88
use App\Models\Access;
99
use App\Models\Category;
10+
use App\Models\Item;
11+
use App\Models\Setting;
1012
use Illuminate\Http\Request;
1113
use App\Helper;
1214
use Spatie\Image\Enums\AlignPosition;
@@ -166,6 +168,14 @@ public function bulk(Request $request)
166168

167169
public function destroy(Category $item)
168170
{
171+
if (Setting::where('type','CATEGORY')->where('raw',$item->id)->count() > 0){
172+
$msg = __("You can't delete this item while using it in setting.");
173+
return redirect()->back()->withErrors($msg);
174+
}
175+
if (Item::where('menuable_type',Category::class)->where('menuable_type',$item->id)->count() > 0){
176+
$msg = __("You can't delete this item while using it in menu.");
177+
return redirect()->back()->withErrors($msg);
178+
}
169179
return parent::delete($item);
170180
}
171181

app/Http/Controllers/Admin/GroupController.php

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use App\Http\Requests\GroupSaveRequest;
88
use App\Models\Access;
99
use App\Models\Group;
10+
use App\Models\Item;
11+
use App\Models\Setting;
1012
use Illuminate\Http\Request;
1113
use App\Helper;
1214
use Spatie\Image\Enums\AlignPosition;
@@ -162,6 +164,14 @@ public function bulk(Request $request)
162164

163165
public function destroy(Group $item)
164166
{
167+
if (Setting::where('type','GROUP')->where('raw',$item->id)->count() > 0){
168+
$msg = __("You can't delete this item while using it in setting.");
169+
return redirect()->back()->withErrors($msg);
170+
}
171+
if (Item::where('menuable_type',Group::class)->where('menuable_type',$item->id)->count() > 0){
172+
$msg = __("You can't delete this item while using it in menu.");
173+
return redirect()->back()->withErrors($msg);
174+
}
165175
return parent::delete($item);
166176
}
167177

resources/lang/fa.json

+7
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
"Customer mobile": "موبایل مشتری",
163163
"Customers": "مشتری‌ها",
164164
"Customers list": "فهرست مشتری‌ها",
165+
"Customize theme": "سفارشی سازی قالب",
165166
"DEMO VERSION": "نگارش آزمایشی",
166167
"Dashboard": "پیشخوان",
167168
"Date": "تاریخ",
@@ -232,6 +233,7 @@
232233
"Extra description": "توضیحات اضافه",
233234
"Failed Invoices": "صورت حساب‌های ناموفق",
234235
"False": "خیر",
236+
"Fast contact form": "دسترسی سریع تماس",
235237
"Favorites": "علاقه‌مندی‌ها",
236238
"Feature image": "تصویر شاخص",
237239
"Female": "مونث",
@@ -264,6 +266,7 @@
264266
"Guest": "میهمان",
265267
"GuestLogs list": "فهرست لاگ میهمان ها",
266268
"Height": "قد",
269+
"Hello world": "سلام دنیا",
267270
"Home": "خانه",
268271
"ID": "",
269272
"Icon": "نماد",
@@ -432,6 +435,7 @@
432435
"SVG image": "تصویر SVG",
433436
"Save": "ذخیره",
434437
"Save all settings": "ذخیره همه تنظیمات",
438+
"Save and build": "ذخیره و ساخت",
435439
"Search": "جستجو",
436440
"Search & Filter": "جستجو و صافی",
437441
"Search for": "جستجو برای",
@@ -454,6 +458,7 @@
454458
"Setting of website updated": "تنظیمات به روز شدند",
455459
"Settings": "تنظیمات",
456460
"Sex": "جنسیت",
461+
"Shop": "خرید",
457462
"Shopping card": "سبد خرید",
458463
"Show": "نمایش",
459464
"Show list": "نمایش فهرست",
@@ -560,6 +565,8 @@
560565
"You can create \/ edit clip as draft, publish it when you want": "شما میتوانید کلیپ را ایجاد و ویرایش کنید، هر زمان که خواستید آن را منتشر کنید",
561566
"You can leave the slug empty; it will be generated automatically.": "شما می‌توانید نامک را خالی بگذارید به صورت خودکار ساخته شود",
562567
"You can't change email or password in demo version": "در نگارش آزمایشی امکان تعویض رایانامه یا گذرواژه وجود ندارد",
568+
"You can't delete this item while using it in menu.": "شما نمی‌توانید این مورد را مادامی که در فهرست استفاده می‌کند حذف کنید.",
569+
"You can't delete this item while using it in setting.": "شما نمی‌توانید این مورد را مادامی که در تنظیمات استفاده می‌کند حذف کنید.",
563570
"You don't have access this action": "شما دسترسی لازم برای این بخش را ندارید",
564571
"You don't have any comments, We are so pleased to hear your look-out": "شما هیچ دیدگاهی تاکنون ارسال نکرده‌اید، از شما تقاضا داریم تجربیات و نگرش خود را برای ما ارسال کنید، چون بسیار ارزشمند است",
565572
"You have some products in your shopping card.": "در سبد خرید شما محصول وجود دارد",

0 commit comments

Comments
 (0)