All Destroy Method Updated
This commit is contained in:
parent
4b70fe3b23
commit
9d99fdf186
|
|
@ -200,24 +200,16 @@ class CustomerController extends Controller
|
|||
$customer = $this->customerRepository->findorFail($id);
|
||||
|
||||
try {
|
||||
|
||||
if (! $this->customerRepository->checkIfCustomerHasOrderPendingOrProcessing($customer)) {
|
||||
|
||||
$this->customerRepository->delete($id);
|
||||
} else {
|
||||
|
||||
session()->flash('error', trans('admin::app.response.order-pending', ['name' => 'Customer']));
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Customer'])]);
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Customer']));
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => trans('admin::app.response.order-pending', ['name' => 'Customer'])], 400);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Customer']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Customer'])], 400);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -128,21 +128,23 @@ class CustomerGroupController extends Controller
|
|||
$customerGroup = $this->customerGroupRepository->findOrFail($id);
|
||||
|
||||
if ($customerGroup->is_user_defined == 0) {
|
||||
session()->flash('warning', trans('admin::app.customers.customers.group-default'));
|
||||
} elseif (count($customerGroup->customers) > 0) {
|
||||
session()->flash('warning', trans('admin::app.response.customer-associate', ['name' => 'Customer Group']));
|
||||
} else {
|
||||
try {
|
||||
$this->customerGroupRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Customer Group']));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Customer Group']));
|
||||
}
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.customers.customers.group-default'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
if (count($customerGroup->customers) > 0) {
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.customer-associate', ['name' => 'Customer Group']),
|
||||
], 400);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->customerGroupRepository->delete($id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Customer Group'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Customer Group'])], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,20 +140,18 @@ class AttributeController extends Controller
|
|||
$attribute = $this->attributeRepository->findOrFail($id);
|
||||
|
||||
if (! $attribute->is_user_defined) {
|
||||
session()->flash('error', trans('admin::app.response.user-define-error', ['name' => 'Attribute']));
|
||||
} else {
|
||||
try {
|
||||
$this->attributeRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Attribute']));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Attribute']));
|
||||
}
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.user-define-error', ['name' => 'Attribute']),
|
||||
], 400);
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
try {
|
||||
$this->attributeRepository->delete($id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Attribute'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Attribute'])], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -140,24 +140,30 @@ class AttributeFamilyController extends Controller
|
|||
$attributeFamily = $this->attributeFamilyRepository->findOrFail($id);
|
||||
|
||||
if ($this->attributeFamilyRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.response.last-delete-error', ['name' => 'Family']));
|
||||
|
||||
} elseif ($attributeFamily->products()->count()) {
|
||||
session()->flash('error', trans('admin::app.response.attribute-product-error', ['name' => 'Attribute family']));
|
||||
} else {
|
||||
try {
|
||||
$this->attributeFamilyRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Family']));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Family']));
|
||||
}
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.last-delete-error', ['name' => 'Family']),
|
||||
], 400);
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
if ($attributeFamily->products()->count()) {
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.attribute-product-error', ['name' => 'Attribute family']),
|
||||
], 400);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->attributeFamilyRepository->delete($id);
|
||||
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.delete-success', ['name' => 'Family']),
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.delete-failed', ['name' => 'Family']),
|
||||
], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -136,14 +136,10 @@ class PageController extends Controller
|
|||
$page = $this->cmsRepository->findOrFail($id);
|
||||
|
||||
if ($page->delete()) {
|
||||
session()->flash('success', trans('admin::app.cms.pages.delete-success'));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
return response()->json(['message' => trans('admin::app.cms.pages.delete-success')]);
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.cms.pages.delete-failure'));
|
||||
|
||||
return response()->json(['message' => false], 200);
|
||||
return response()->json(['message' => trans('admin::app.cms.pages.delete-failure')], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -212,13 +212,9 @@ class CartRuleController extends Controller
|
|||
try {
|
||||
$this->cartRuleRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Cart Rule']));
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Cart Rule'])]);
|
||||
} catch (Exception $e) {}
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Cart Rule']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Cart Rule'])], 400);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,13 +156,9 @@ class CatalogRuleController extends Controller
|
|||
try {
|
||||
$this->catalogRuleRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Catalog Rule']));
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Catalog Rule'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Catalog Rule']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Catalog Rule'])], 400);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,20 +136,16 @@ class CategoryController extends Controller
|
|||
$category = $this->categoryRepository->findOrFail($id);
|
||||
|
||||
if ($this->isCategoryDeletable($category)) {
|
||||
session()->flash('warning', trans('admin::app.response.delete-category-root', ['name' => 'Category']));
|
||||
} else {
|
||||
try {
|
||||
$this->categoryRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Category']));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Category']));
|
||||
}
|
||||
return response()->json(['message' => trans('admin::app.response.delete-category-root', ['name' => 'Category'])], 400);
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
try {
|
||||
$this->categoryRepository->delete($id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Category'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Category'])], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -204,7 +200,7 @@ class CategoryController extends Controller
|
|||
$product_count += $category->products->count();
|
||||
}
|
||||
|
||||
return response()->json(['product_count' => $product_count], 200);
|
||||
return response()->json(['product_count' => $product_count]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -187,20 +187,16 @@ class ChannelController extends Controller
|
|||
$channel = $this->channelRepository->findOrFail($id);
|
||||
|
||||
if ($channel->code == config('app.channel')) {
|
||||
session()->flash('error', trans('admin::app.settings.channels.last-delete-error'));
|
||||
} else {
|
||||
try {
|
||||
$this->channelRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.settings.channels.delete-success'));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Channel']));
|
||||
}
|
||||
return response()->json(['message' => trans('admin::app.settings.channels.last-delete-error')], 400);
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
try {
|
||||
$this->channelRepository->delete($id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.settings.channels.delete-success')]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Channel'])], 400);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -121,21 +121,18 @@ class CurrencyController extends Controller
|
|||
$this->currencyRepository->findOrFail($id);
|
||||
|
||||
if ($this->currencyRepository->count() == 1) {
|
||||
session()->flash('warning', trans('admin::app.settings.currencies.last-delete-error'));
|
||||
} else {
|
||||
try {
|
||||
$this->currencyRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.settings.currencies.delete-success'));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Currency']));
|
||||
}
|
||||
return response()->json(['message' => trans('admin::app.settings.currencies.last-delete-error')], 400);
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
try {
|
||||
$this->currencyRepository->delete($id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.settings.currencies.delete-success')]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Currency'])], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -158,15 +158,11 @@ class ExchangeRateController extends Controller
|
|||
try {
|
||||
$this->exchangeRateRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.settings.exchange_rates.delete-success'));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
return response()->json(['message' => trans('admin::app.settings.exchange_rates.delete-success')]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
||||
session()->flash('error', trans('admin::app.response.delete-error', ['name' => 'Exchange rate']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-error', ['name' => 'Exchange rate'])], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,19 +123,15 @@ class LocaleController extends Controller
|
|||
$this->localeRepository->findOrFail($id);
|
||||
|
||||
if ($this->localeRepository->count() == 1) {
|
||||
session()->flash('warning', trans('admin::app.settings.locales.last-delete-error'));
|
||||
} else {
|
||||
try {
|
||||
$this->localeRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.settings.locales.delete-success'));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Locale']));
|
||||
}
|
||||
return response()->json(['message' => trans('admin::app.settings.locales.last-delete-error')], 400);
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
try {
|
||||
$this->localeRepository->delete($id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.settings.locales.delete-success')]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Locale'])], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,15 +165,11 @@ class SliderController extends Controller
|
|||
try {
|
||||
$this->sliderRepository->delete($id);
|
||||
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.delete-success', ['name' => 'Slider']),
|
||||
], 200);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Slider'])]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.delete-failed', ['name' => 'Slider']),
|
||||
], 500);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Slider'])], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,15 +104,11 @@ class SubscriptionController extends Controller
|
|||
try {
|
||||
$this->subscribersListRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Subscriber']));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Subscriber'])]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Subscriber']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Subscriber'])], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,21 +120,17 @@ class InventorySourceController extends Controller
|
|||
$this->inventorySourceRepository->findOrFail($id);
|
||||
|
||||
if ($this->inventorySourceRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.settings.inventory_sources.last-delete-error'));
|
||||
} else {
|
||||
try {
|
||||
$this->inventorySourceRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.settings.inventory_sources.delete-success'));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Inventory source']));
|
||||
}
|
||||
return response()->json(['message' => trans('admin::app.settings.inventory_sources.last-delete-error')], 400);
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
try {
|
||||
$this->inventorySourceRepository->delete($id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.settings.inventory_sources.delete-success')]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Inventory source'])], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,13 +129,9 @@ class CampaignController extends Controller
|
|||
try {
|
||||
$this->campaignRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.marketing.campaigns.delete-success'));
|
||||
return response()->json(['message' => trans('admin::app.marketing.campaigns.delete-success')]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Email Campaign']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Email Campaign'])], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,13 +131,9 @@ class EventController extends Controller
|
|||
try {
|
||||
$this->eventRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.marketing.events.delete-success'));
|
||||
return response()->json(['message' => trans('admin::app.marketing.events.delete-success')]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Event']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Event'])], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,13 +125,9 @@ class TemplateController extends Controller
|
|||
try {
|
||||
$this->templateRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.marketing.templates.delete-success'));
|
||||
return response()->json(['message' => trans('admin::app.marketing.templates.delete-success')]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Email Template']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Email Template'])], 400);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ class ProductController extends Controller
|
|||
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.delete-success', ['name' => 'Product']),
|
||||
], 200);
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,16 +90,12 @@ class ReviewController extends Controller
|
|||
try {
|
||||
$this->productReviewRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Review']));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Review'])]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-failed', ['name' => 'Review']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Review'])], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ class OnepageController extends Controller
|
|||
'success' => true,
|
||||
'message' => trans('shop::app.checkout.total.coupon-applied'),
|
||||
'result' => $result,
|
||||
], 200);
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
|
|
@ -356,7 +356,7 @@ class OnepageController extends Controller
|
|||
'data' => [
|
||||
'grand_total' => core()->currency(Cart::getCart()->grand_total),
|
||||
],
|
||||
], 200);
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
|
|
|
|||
|
|
@ -139,13 +139,9 @@ class TaxCategoryController extends Controller
|
|||
try {
|
||||
$this->taxCategoryRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Tax Category']));
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Tax Category'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Tax Category']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Tax Category'])], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,14 +144,10 @@ class TaxRateController extends Controller
|
|||
try {
|
||||
$this->taxRateRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Tax Rate']));
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Tax Rate'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Tax Rate']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Tax Rate'])], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -149,21 +149,19 @@ class RoleController extends Controller
|
|||
$role = $this->roleRepository->findOrFail($id);
|
||||
|
||||
if ($role->admins->count() >= 1) {
|
||||
session()->flash('error', trans('admin::app.response.being-used', ['name' => 'Role', 'source' => 'Admin User']));
|
||||
} else if ($this->roleRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.response.last-delete-error', ['name' => 'Role']));
|
||||
} else {
|
||||
try {
|
||||
$this->roleRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Role']));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Role']));
|
||||
}
|
||||
return response()->json(['message' => trans('admin::app.response.being-used', ['name' => 'Role', 'source' => 'Admin User'])], 400);
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
if ($this->roleRepository->count() == 1) {
|
||||
return response()->json(['message' => trans('admin::app.response.last-delete-error', ['name' => 'Role'])], 400);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->roleRepository->delete($id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Role'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Role'])], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,26 +149,22 @@ class UserController extends Controller
|
|||
$this->adminRepository->findOrFail($id);
|
||||
|
||||
if ($this->adminRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.response.last-delete-error', ['name' => 'Admin']));
|
||||
} else {
|
||||
if (auth()->guard('admin')->user()->id == $id) {
|
||||
return response()->json([
|
||||
'redirect' => route('super.users.confirm', ['id' => $id]),
|
||||
]);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->adminRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Admin']));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Admin']));
|
||||
}
|
||||
return response()->json(['message' => trans('admin::app.response.last-delete-error', ['name' => 'Admin'])], 400);
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
if (auth()->guard('admin')->user()->id == $id) {
|
||||
return response()->json([
|
||||
'redirect' => route('super.users.confirm', ['id' => $id]),
|
||||
]);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->adminRepository->delete($id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Admin'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Admin'])], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ class CategoryController extends Controller
|
|||
* Category Repository object
|
||||
*
|
||||
* @var \Webkul\Category\Repositories\CategoryRepository
|
||||
*/
|
||||
*/
|
||||
protected $categoryRepository;
|
||||
|
||||
/**
|
||||
* VelocityCategory Repository object
|
||||
*
|
||||
* @var \Webkul\Velocity\Repositories\CategoryRepository
|
||||
*/
|
||||
*/
|
||||
protected $velocityCategoryRepository;
|
||||
|
||||
/**
|
||||
|
|
@ -32,8 +32,7 @@ class CategoryController extends Controller
|
|||
public function __construct(
|
||||
CategoryRepository $categoryRepository,
|
||||
VelocityCategoryRepository $velocityCategoryRepository
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->categoryRepository = $categoryRepository;
|
||||
|
||||
$this->velocityCategoryRepository = $velocityCategoryRepository;
|
||||
|
|
@ -125,14 +124,10 @@ class CategoryController extends Controller
|
|||
try {
|
||||
$this->velocityCategoryRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Category Menu']));
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Category Menu'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Category Menu']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Category Menu'])], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -156,4 +151,4 @@ class CategoryController extends Controller
|
|||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,14 +154,10 @@ class ContentController extends Controller
|
|||
try {
|
||||
$this->contentRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Content']));
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Content'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Content']));
|
||||
}
|
||||
|
||||
return response()->json(['message' => false], 400);
|
||||
return response()->json(['message' => trans('admin::app.response.delete-failed', ['name' => 'Content'])], 400);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class CartController extends Controller
|
|||
];
|
||||
}
|
||||
|
||||
return response()->json($response, 200);
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,6 +140,6 @@ class CartController extends Controller
|
|||
'status' => 'danger',
|
||||
'label' => trans('velocity::app.shop.general.alert.error'),
|
||||
'message' => trans('velocity::app.error.something_went_wrong'),
|
||||
], 200);
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -94,13 +94,13 @@ class ComparisonController extends Controller
|
|||
'status' => 'success',
|
||||
'message' => trans('velocity::app.customer.compare.added'),
|
||||
'label' => trans('velocity::app.shop.general.alert.success'),
|
||||
], 201);
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'label' => trans('velocity::app.shop.general.alert.success'),
|
||||
'message' => trans('velocity::app.customer.compare.already_added'),
|
||||
], 200);
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue