添加后台数据hook 和流程 hook
This commit is contained in:
parent
85edc96d41
commit
407c03bea3
|
|
@ -25,19 +25,35 @@ class AddressController extends Controller
|
|||
'addresses' => AddressResource::collection($addresses),
|
||||
];
|
||||
|
||||
return $data;
|
||||
return hook_filter('admin.address.index.data', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request, int $customerId)
|
||||
{
|
||||
$address = AddressService::addForCustomer($customerId, $request->all());
|
||||
$requestData = $request->all();
|
||||
|
||||
$beforeData = [
|
||||
'customer_id' => $customerId,
|
||||
'data' => $requestData,
|
||||
];
|
||||
hook_action('admin.address.store.before', $beforeData);
|
||||
$address = AddressService::addForCustomer($customerId, $requestData);
|
||||
hook_action('admin.address.store.after', $address);
|
||||
|
||||
return json_success(trans('common.created_success'), $address);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $customerId, int $addressId)
|
||||
{
|
||||
$requestData = $request->all();
|
||||
$beforeData = [
|
||||
'customer_id' => $customerId,
|
||||
'address_id' => $addressId,
|
||||
'data' => $requestData,
|
||||
];
|
||||
hook_action('admin.address.update.before', $beforeData);
|
||||
$address = AddressService::update($addressId, $request->all());
|
||||
hook_action('admin.address.update.after', $address);
|
||||
|
||||
return json_success(trans('common.updated_success'), $address);
|
||||
}
|
||||
|
|
@ -45,6 +61,7 @@ class AddressController extends Controller
|
|||
public function destroy(Request $request, int $customerId, int $addressId)
|
||||
{
|
||||
AddressRepo::delete($addressId);
|
||||
hook_action('admin.address.destroy.after', $addressId);
|
||||
|
||||
return json_success(trans('common.deleted_success'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class AdminRoleController extends Controller
|
|||
$data = [
|
||||
'roles' => Role::query()->get(),
|
||||
];
|
||||
$data = hook_filter('admin.admin_role.index.data', $data);
|
||||
|
||||
return view('admin::pages.admin_roles.index', $data);
|
||||
}
|
||||
|
|
@ -36,6 +37,8 @@ class AdminRoleController extends Controller
|
|||
'permissions' => $permissionRepo->getAllPermissions(),
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.admin_role.create.data', $data);
|
||||
|
||||
return view('admin::pages.admin_roles.edit', $data);
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +51,7 @@ class AdminRoleController extends Controller
|
|||
'permissions' => $permissionRepo->getAllPermissions(),
|
||||
'role' => $role,
|
||||
];
|
||||
$data = hook_filter('admin.admin_role.edit.data', $data);
|
||||
|
||||
return view('admin::pages.admin_roles.edit', $data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class AdminUserController extends Controller
|
|||
'admin_users' => AdminUserRepo::getAdminUsers(),
|
||||
'admin_roles' => Role::query()->get(),
|
||||
];
|
||||
$data = hook_filter('admin.admin_user.index.data', $data);
|
||||
|
||||
return view('admin::pages.admin_users.index', $data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class AttributeController extends Controller
|
|||
'attribute_list_format' => AttributeResource::collection($attributes),
|
||||
'attribute_group' => AttributeGroupRepo::getList(),
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.attribute.index.data', $data);
|
||||
if ($request->expectsJson()) {
|
||||
return json_success(trans('success'), $data);
|
||||
}
|
||||
|
|
@ -43,6 +43,7 @@ class AttributeController extends Controller
|
|||
'attribute' => (new AttributeDetailResource(AttributeRepo::find($id)))->jsonSerialize(),
|
||||
'attribute_group' => AttributeGroupRepo::getList(),
|
||||
];
|
||||
$data = hook_filter('admin.attribute.show.data', $data);
|
||||
|
||||
return view('admin::pages.attributes.form', $data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class AttributeGroupController extends Controller
|
|||
$data = [
|
||||
'attribute_groups' => AttributeGroupRepo::getList(),
|
||||
];
|
||||
$data = hook_filter('admin.attribute_group.index.data', $data);
|
||||
|
||||
return view('admin::pages.attribute_group.index', $data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class BrandController extends Controller
|
|||
$data = [
|
||||
'brands' => $brands,
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.brand.index.data', $data);
|
||||
if ($request->expectsJson()) {
|
||||
return json_success(trans('common.success'), $data);
|
||||
}
|
||||
|
|
@ -44,7 +44,10 @@ class BrandController extends Controller
|
|||
*/
|
||||
public function store(Request $request): array
|
||||
{
|
||||
$beforeData = $request->all();
|
||||
hook_action('admin.brand.store.before', $beforeData);
|
||||
$brand = BrandRepo::create($request->all());
|
||||
hook_action('admin.brand.store.after', $brand);
|
||||
|
||||
return json_success(trans('common.created_success'), $brand);
|
||||
}
|
||||
|
|
@ -54,14 +57,22 @@ class BrandController extends Controller
|
|||
*/
|
||||
public function update(Request $request, int $id): array
|
||||
{
|
||||
$requestData = $request->all();
|
||||
$beforeData = [
|
||||
'brand_id' => $id,
|
||||
'data' => $requestData,
|
||||
];
|
||||
hook_action('admin.brand.update.before', $beforeData);
|
||||
$brand = BrandRepo::update($id, $request->all());
|
||||
hook_action('admin.brand.update.after', $brand);
|
||||
|
||||
return json_success(trans('common.updated_success'), $brand);
|
||||
}
|
||||
|
||||
public function destroy(int $addressId): array
|
||||
public function destroy(int $brandId): array
|
||||
{
|
||||
BrandRepo::delete($addressId);
|
||||
BrandRepo::delete($brandId);
|
||||
hook_action('admin.brand.destroy.after', $brandId);
|
||||
|
||||
return json_success(trans('common.deleted_success'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class CategoryController extends Controller
|
|||
$data = [
|
||||
'categories' => CategoryResource::collection($categories),
|
||||
];
|
||||
$data = hook_filter('admin.category.index.data', $data);
|
||||
|
||||
return view('admin::pages.categories.index', $data);
|
||||
}
|
||||
|
|
@ -54,6 +55,7 @@ class CategoryController extends Controller
|
|||
public function destroy(Request $request, Category $category): array
|
||||
{
|
||||
CategoryRepo::delete($category);
|
||||
hook_action('admin.category.destroy.after', $category);
|
||||
|
||||
return json_success(trans('common.deleted_success'));
|
||||
}
|
||||
|
|
@ -78,13 +80,16 @@ class CategoryController extends Controller
|
|||
'categories' => CategoryRepo::flatten(locale()),
|
||||
'_redirect' => $this->getRedirect(),
|
||||
];
|
||||
$data = hook_filter('admin.category.form.data', $data);
|
||||
|
||||
return view('admin::pages.categories.form', $data);
|
||||
}
|
||||
|
||||
protected function save(Request $request, ?Category $category = null)
|
||||
{
|
||||
(new CategoryService())->createOrUpdate($request->all(), $category);
|
||||
$category = (new CategoryService())->createOrUpdate($request->all(), $category);
|
||||
|
||||
hook_action('admin.category.save.after', $category);
|
||||
|
||||
return redirect($this->getRedirect())->with('success', 'Category created successfully');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class CountryController extends Controller
|
|||
$data = [
|
||||
'country' => $countries,
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.country.index.data', $data);
|
||||
if ($request->expectsJson()) {
|
||||
return json_success(trans('common.success'), $data);
|
||||
}
|
||||
|
|
@ -33,22 +33,28 @@ class CountryController extends Controller
|
|||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$Country = CountryRepo::create($request->only('name', 'code', 'sort_order', 'status'));
|
||||
$country = CountryRepo::create($request->only('name', 'code', 'sort_order', 'status'));
|
||||
|
||||
return json_success(trans('common.created_success'), $Country);
|
||||
hook_action('admin.country.store.after', $country);
|
||||
|
||||
return json_success(trans('common.created_success'), $country);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$Country = CountryRepo::update($id, $request->only('name', 'code', 'sort_order', 'status'));
|
||||
$country = CountryRepo::update($id, $request->only('name', 'code', 'sort_order', 'status'));
|
||||
|
||||
return json_success(trans('common.updated_success'), $Country);
|
||||
hook_action('admin.country.store.after', $country);
|
||||
|
||||
return json_success(trans('common.updated_success'), $country);
|
||||
}
|
||||
|
||||
public function destroy(int $id)
|
||||
{
|
||||
CountryRepo::delete($id);
|
||||
|
||||
hook_action('admin.country.destroy.after', $id);
|
||||
|
||||
return json_success(trans('common.deleted_success'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class CurrencyController extends Controller
|
|||
$data = [
|
||||
'currencies' => $currencies,
|
||||
];
|
||||
$data = hook_filter('admin.currency.index.data', $data);
|
||||
|
||||
return view('admin::pages.currencies.index', $data);
|
||||
}
|
||||
|
|
@ -42,6 +43,7 @@ class CurrencyController extends Controller
|
|||
'status' => (int) $request->get('status', 0),
|
||||
];
|
||||
$currency = CurrencyRepo::create($data);
|
||||
hook_action('admin.currency.store.after', $currency);
|
||||
|
||||
return json_success(trans('common.created_success'), $currency);
|
||||
}
|
||||
|
|
@ -65,6 +67,7 @@ class CurrencyController extends Controller
|
|||
public function destroy(Request $request, int $currencyId)
|
||||
{
|
||||
CurrencyRepo::delete($currencyId);
|
||||
hook_action('admin.currency.destroy.after', $currencyId);
|
||||
|
||||
return json_success(trans('common.deleted_success'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class CustomerController extends Controller
|
|||
'customer_groups' => CustomerGroupDetail::collection(CustomerGroupRepo::list())->jsonSerialize(),
|
||||
'type' => 'customer',
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.customer.index.data', $data);
|
||||
if ($request->expectsJson()) {
|
||||
return json_success(trans('success'), $data);
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ class CustomerController extends Controller
|
|||
'customer_groups' => CustomerGroupDetail::collection(CustomerGroupRepo::list())->jsonSerialize(),
|
||||
'type' => 'trashed',
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.customer.trashed.data', $data);
|
||||
if ($request->expectsJson()) {
|
||||
return json_success(trans('success'), $data);
|
||||
}
|
||||
|
|
@ -80,6 +80,7 @@ class CustomerController extends Controller
|
|||
'country_id' => system_setting('base.country_id'),
|
||||
'_redirect' => $this->getRedirect(),
|
||||
];
|
||||
$data = hook_filter('admin.customer.edit.data', $data);
|
||||
|
||||
return view('admin::pages.customers.form', $data);
|
||||
}
|
||||
|
|
@ -92,12 +93,15 @@ class CustomerController extends Controller
|
|||
}
|
||||
$customer = CustomerRepo::update($customerId, $data);
|
||||
|
||||
hook_action('admin.customer.update.after', $customer);
|
||||
|
||||
return json_success(trans('common.updated_success'), $customer);
|
||||
}
|
||||
|
||||
public function destroy(Request $request, int $customerId)
|
||||
{
|
||||
CustomerRepo::delete($customerId);
|
||||
hook_action('admin.customer.destroy.after', $customerId);
|
||||
|
||||
return json_success(trans('common.deleted_success'));
|
||||
}
|
||||
|
|
@ -105,20 +109,23 @@ class CustomerController extends Controller
|
|||
public function restore(Request $request, int $customerId)
|
||||
{
|
||||
CustomerRepo::restore($customerId);
|
||||
hook_action('admin.customer.restore.after', $customerId);
|
||||
|
||||
return json_success(trans('common.restored_success'));
|
||||
}
|
||||
|
||||
public function forceDelete(Request $request, int $customerId)
|
||||
{
|
||||
$customer = CustomerRepo::forceDelete($customerId);
|
||||
CustomerRepo::forceDelete($customerId);
|
||||
hook_action('admin.customer.force_delete.after', $customerId);
|
||||
|
||||
return json_success(trans('common.success'));
|
||||
}
|
||||
|
||||
public function forceDeleteAll(Request $request)
|
||||
{
|
||||
$customer = CustomerRepo::forceDeleteAll();
|
||||
CustomerRepo::forceDeleteAll();
|
||||
hook_action('admin.customer.force_delete_all.after', ['module' => 'customer']);
|
||||
|
||||
return json_success(trans('common.success'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class CustomerGroupController extends Controller
|
|||
'customer_groups' => $customers,
|
||||
'languages' => LanguageRepo::all(),
|
||||
];
|
||||
$data = hook_filter('admin.customer_group.index.data', $data);
|
||||
|
||||
return view('admin::pages.customer_groups.index', $data);
|
||||
}
|
||||
|
|
@ -38,6 +39,8 @@ class CustomerGroupController extends Controller
|
|||
$customerGroup = CustomerGroupService::create($request->all());
|
||||
$customerGroup->load('descriptions', 'description');
|
||||
|
||||
hook_action('admin.customer_group.store.after', $customerGroup);
|
||||
|
||||
return json_success(trans('common.created_success'), $customerGroup);
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +49,8 @@ class CustomerGroupController extends Controller
|
|||
$customerGroup = CustomerGroupService::update($id, $request->all());
|
||||
$customerGroup->load('descriptions', 'description');
|
||||
|
||||
hook_action('admin.customer_group.update.after', $customerGroup);
|
||||
|
||||
return json_success(trans('common.updated_success'), $customerGroup);
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +58,8 @@ class CustomerGroupController extends Controller
|
|||
{
|
||||
CustomerGroupRepo::delete($id);
|
||||
|
||||
hook_action('admin.customer_group.destroy.after', $id);
|
||||
|
||||
return json_success(trans('common.deleted_success'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class DesignController extends Controller
|
|||
'editors' => ['editor-slide_show', 'editor-image401', 'editor-tab_product', 'editor-product', 'editor-image100', 'editor-brand', 'editor-icons', 'editor-rich_text'],
|
||||
'design_settings' => system_setting('base.design_setting'),
|
||||
];
|
||||
$data = hook_filter('admin.design.index.data', $data);
|
||||
|
||||
return view('admin::pages.design.builder.index', $data);
|
||||
}
|
||||
|
|
@ -47,6 +48,7 @@ class DesignController extends Controller
|
|||
'content' => DesignService::handleModuleContent($moduleCode, $content),
|
||||
'design' => (bool) $request->get('design'),
|
||||
];
|
||||
$viewData = hook_filter('admin.design.preview.data', $viewData);
|
||||
|
||||
return view($viewPath, $viewData);
|
||||
}
|
||||
|
|
@ -64,6 +66,8 @@ class DesignController extends Controller
|
|||
$moduleData = DesignService::handleRequestModules($content);
|
||||
SettingRepo::storeValue('design_setting', $moduleData);
|
||||
|
||||
hook_action('admin.design.update.after', $moduleData);
|
||||
|
||||
return json_success(trans('common.updated_success'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class DesignFooterController extends Controller
|
|||
$data = [
|
||||
'design_settings' => system_setting('base.footer_setting'),
|
||||
];
|
||||
$data = hook_filter('admin.design_footer.index.data', $data);
|
||||
|
||||
return view('admin::pages.design.builder.footer', $data);
|
||||
}
|
||||
|
|
@ -37,9 +38,11 @@ class DesignFooterController extends Controller
|
|||
$viewPath = 'layout.footer';
|
||||
|
||||
$viewData = [
|
||||
'view_path' => $viewPath,
|
||||
'footer_content' => FooterRepo::handleFooterData($content),
|
||||
'design' => (bool) $request->get('design'),
|
||||
];
|
||||
$viewData = hook_filter('admin.design_footer.index.data', $viewData);
|
||||
|
||||
return view($viewPath, $viewData);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class DesignMenuController extends Controller
|
|||
$data = [
|
||||
'design_settings' => system_setting('base.menu_setting', []),
|
||||
];
|
||||
$data = hook_filter('admin.design_menu.index.data', $data);
|
||||
|
||||
return view('admin::pages.design.builder.menu', $data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class FileManagerController extends Controller
|
|||
public function index()
|
||||
{
|
||||
$data = (new FileManagerService)->getDirectories();
|
||||
$data = hook_filter('admin.file_manager.index.data', $data);
|
||||
|
||||
return view('admin::pages.file_manager.index', ['directories' => $data]);
|
||||
}
|
||||
|
|
@ -33,7 +34,9 @@ class FileManagerController extends Controller
|
|||
$page = (int) $request->get('page');
|
||||
$perPage = (int) $request->get('per_page');
|
||||
|
||||
return (new FileManagerService)->getFiles($baseFolder, $page, $perPage);
|
||||
$data = (new FileManagerService)->getFiles($baseFolder, $page, $perPage);
|
||||
|
||||
return hook_filter('admin.file_manager.files.data', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -46,7 +49,9 @@ class FileManagerController extends Controller
|
|||
{
|
||||
$baseFolder = $request->get('base_folder');
|
||||
|
||||
return (new FileManagerService)->getDirectories($baseFolder);
|
||||
$data = (new FileManagerService)->getDirectories($baseFolder);
|
||||
|
||||
return hook_filter('admin.file_manager.directories.data', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class LanguageController extends Controller
|
|||
$data = [
|
||||
'languages' => $languages,
|
||||
];
|
||||
$data = hook_filter('admin.language.index.data', $data);
|
||||
|
||||
return view('admin::pages.languages.index', $data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class MarketingController
|
|||
'domain' => str_replace(['http://', 'https://'], '', config('app.url')),
|
||||
'types' => PluginRepo::getTypes(),
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.marketing.index.data', $data);
|
||||
if ($request->expectsJson()) {
|
||||
return json_success(trans('common.success'), $data);
|
||||
}
|
||||
|
|
@ -53,6 +53,9 @@ class MarketingController
|
|||
'domain' => str_replace(['http://', 'https://'], '', config('app.url')),
|
||||
'plugin' => $plugin,
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.marketing.show.data', $data);
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
return $data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class OrderController extends Controller
|
|||
'orders' => OrderList::collection($orders),
|
||||
'statuses' => StateMachineService::getAllStatuses(),
|
||||
];
|
||||
$data = hook_filter('admin.order.index.data', $data);
|
||||
|
||||
return view('admin::pages.orders.index', $data);
|
||||
}
|
||||
|
|
@ -51,6 +52,7 @@ class OrderController extends Controller
|
|||
try {
|
||||
$orders = OrderRepo::filterAll($request->all());
|
||||
$items = OrderSimple::collection($orders)->jsonSerialize();
|
||||
$items = hook_filter('admin.order.export.data', $items);
|
||||
|
||||
return $this->downloadCsv('orders', $items, 'order');
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -71,6 +73,7 @@ class OrderController extends Controller
|
|||
$order->load(['orderTotals', 'orderHistories', 'orderShipments']);
|
||||
$data = hook_filter('admin.order.show.data', ['order' => $order, 'html_items' => []]);
|
||||
$data['statuses'] = StateMachineService::getInstance($order)->nextBackendStatuses();
|
||||
$data = hook_filter('admin.order.show.data', $data);
|
||||
|
||||
return view('admin::pages.orders.form', $data);
|
||||
}
|
||||
|
|
@ -94,6 +97,10 @@ class OrderController extends Controller
|
|||
$stateMachine = new StateMachineService($order);
|
||||
$stateMachine->setShipment($shipment)->changeStatus($status, $comment, $notify);
|
||||
|
||||
$orderStatusData = $request->all();
|
||||
|
||||
hook_action('admin.order.update_status.after', $orderStatusData);
|
||||
|
||||
return json_success(trans('common.updated_success'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ class PageCategoryController extends Controller
|
|||
'page_categories_format' => PageCategoryResource::collection($pageCategoryList)->jsonSerialize(),
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.page_category.index.data', $data);
|
||||
|
||||
return view('admin::pages.page_categories.index', $data);
|
||||
}
|
||||
|
||||
|
|
@ -56,8 +58,12 @@ class PageCategoryController extends Controller
|
|||
public function store(PageCategoryRequest $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$requestData = $request->all();
|
||||
PageCategoryRepo::createOrUpdate($requestData);
|
||||
hook_action('admin.page_category.store.before', $requestData);
|
||||
$pageCategory = PageCategoryRepo::createOrUpdate($requestData);
|
||||
|
||||
hook_action('admin.page_category.store.after', $pageCategory);
|
||||
|
||||
return redirect(admin_route('page_categories.index'));
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -79,6 +85,8 @@ class PageCategoryController extends Controller
|
|||
'descriptions' => $descriptions,
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.page_category.edit.data', $data);
|
||||
|
||||
return view('admin::pages.page_categories.form', $data);
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +103,9 @@ class PageCategoryController extends Controller
|
|||
try {
|
||||
$requestData = $request->all();
|
||||
$requestData['id'] = $pageCategory->id;
|
||||
PageCategoryRepo::createOrUpdate($requestData);
|
||||
hook_action('admin.page_category.update.before', $requestData);
|
||||
$pageCategory = PageCategoryRepo::createOrUpdate($requestData);
|
||||
hook_action('admin.page_category.store.after', $pageCategory);
|
||||
|
||||
return redirect()->to(admin_route('page_categories.index'));
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -113,6 +123,7 @@ class PageCategoryController extends Controller
|
|||
public function destroy(Request $request, int $pageId): array
|
||||
{
|
||||
PageCategoryRepo::deleteById($pageId);
|
||||
hook_action('admin.page_category.store.after', $pageId);
|
||||
|
||||
return json_success(trans('common.deleted_success'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class PluginController extends Controller
|
|||
{
|
||||
$plugins = app('plugin')->getPlugins();
|
||||
$data['plugins'] = array_values(PluginResource::collection($plugins)->jsonSerialize());
|
||||
$data = hook_filter('admin.plugin.index.data', $data);
|
||||
|
||||
return view('admin::pages.plugins.index', $data);
|
||||
}
|
||||
|
|
@ -82,7 +83,14 @@ class PluginController extends Controller
|
|||
$columnView = $plugin->getColumnView();
|
||||
$view = $columnView ?: 'admin::pages.plugins.form';
|
||||
|
||||
return view($view, ['plugin' => $plugin]);
|
||||
$data = [
|
||||
'view' => $view,
|
||||
'plugin' => $plugin,
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.plugin.edit.data', $data);
|
||||
|
||||
return view($view, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class ProductController extends Controller
|
|||
'type' => 'products',
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.product.index.data', $data);
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
return $products;
|
||||
}
|
||||
|
|
@ -49,6 +51,8 @@ class ProductController extends Controller
|
|||
'type' => 'trashed',
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.product.trashed.data', $data);
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
return $products;
|
||||
}
|
||||
|
|
@ -64,7 +68,15 @@ class ProductController extends Controller
|
|||
public function store(ProductRequest $request)
|
||||
{
|
||||
try {
|
||||
(new ProductService)->create($request->all());
|
||||
$requestData = $request->all();
|
||||
$product = (new ProductService)->create($requestData);
|
||||
|
||||
$data = [
|
||||
'request_data' => $requestData,
|
||||
'product' => $product,
|
||||
];
|
||||
|
||||
hook_action('admin.product.store.after', $data);
|
||||
|
||||
return redirect()->to(admin_route('products.index'))
|
||||
->with('success', trans('common.created_success'));
|
||||
|
|
@ -83,9 +95,14 @@ class ProductController extends Controller
|
|||
public function update(ProductRequest $request, Product $product)
|
||||
{
|
||||
try {
|
||||
$productData = $request->all();
|
||||
$product = (new ProductService)->update($product, $productData);
|
||||
hook_action('admin.product.update.after', ['product' => $product, 'data' => $productData]);
|
||||
$requestData = $request->all();
|
||||
$product = (new ProductService)->update($product, $requestData);
|
||||
|
||||
$data = [
|
||||
'request_data' => $requestData,
|
||||
'product' => $product,
|
||||
];
|
||||
hook_action('admin.product.update.after', $data);
|
||||
|
||||
return redirect()->to($this->getRedirect())->with('success', trans('common.updated_success'));
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -96,6 +113,7 @@ class ProductController extends Controller
|
|||
public function destroy(Request $request, Product $product)
|
||||
{
|
||||
$product->delete();
|
||||
hook_action('admin.product.destroy.after', $product);
|
||||
|
||||
return json_success(trans('common.deleted_success'));
|
||||
}
|
||||
|
|
@ -105,6 +123,8 @@ class ProductController extends Controller
|
|||
$productId = $request->id ?? 0;
|
||||
Product::withTrashed()->find($productId)->restore();
|
||||
|
||||
hook_action('admin.product.restore.after', $productId);
|
||||
|
||||
return ['success' => true];
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +194,10 @@ class ProductController extends Controller
|
|||
|
||||
public function destroyByIds(Request $request)
|
||||
{
|
||||
ProductRepo::DeleteByIds($request->get('ids'));
|
||||
$productIds = $request->get('ids');
|
||||
ProductRepo::DeleteByIds($productIds);
|
||||
|
||||
hook_action('admin.product.destroy_by_ids.after', $productIds);
|
||||
|
||||
return json_success(trans('common.deleted_success'), []);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ class RegionController
|
|||
'countries' => CountryRepo::all(),
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.region.index.data', $data);
|
||||
|
||||
return view('admin::pages.regions.index', $data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ class RmaController extends Controller
|
|||
'rmas_format' => RmaDetail::collection($rmas)->jsonSerialize(),
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.rma.index.data', $data);
|
||||
|
||||
return view('admin::pages.rmas.index', $data);
|
||||
}
|
||||
|
||||
|
|
@ -43,25 +45,30 @@ class RmaController extends Controller
|
|||
'types' => RmaRepo::getTypes(),
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.rma.show.data', $data);
|
||||
|
||||
return view('admin::pages.rmas.info', $data);
|
||||
}
|
||||
|
||||
public function addHistory(Request $request, int $id)
|
||||
{
|
||||
RmaRepo::addHistory($id, $request->only('status', 'notify', 'comment'));
|
||||
$data = [
|
||||
'rma' => (new RmaDetail(RmaRepo::find($id)))->jsonSerialize(),
|
||||
'statuses' => RmaRepo::getStatuses(),
|
||||
];
|
||||
|
||||
$data = [
|
||||
'rma' => (new RmaDetail(RmaRepo::find($id)))->jsonSerialize(),
|
||||
'statuses' => RmaRepo::getStatuses(),
|
||||
];
|
||||
hook_filter('admin.rma.add_history.data', $data);
|
||||
|
||||
return json_success(trans('common.updated_success'), $data);
|
||||
return json_success(trans('common.updated_success'), $data);
|
||||
}
|
||||
|
||||
public function destroy(int $id): array
|
||||
{
|
||||
RmaRepo::delete($id);
|
||||
|
||||
hook_action('admin.rma.destroy.after', $id);
|
||||
|
||||
return json_success(trans('common.deleted_success'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ class RmaReasonController extends Controller
|
|||
'rmaReasons' => RmaReasonDetail::collection($rmaReasons)->jsonSerialize(),
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.rma_reason.index.data', $data);
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
return json_success(trans('common.success'), $data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ class SettingController extends Controller
|
|||
'themes' => $themes,
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.setting.index.data', $data);
|
||||
|
||||
return view('admin::pages.setting', $data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class TaxClassController extends Controller
|
|||
'bases' => TaxClassRepo::BASE_TYPES,
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.tax_class.index.data', $data);
|
||||
|
||||
return view('admin::pages.tax_classes.index', $data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class TaxRateController
|
|||
'regions' => Region::all(),
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.tax_rate.index.data', $data);
|
||||
|
||||
return view('admin::pages.tax_rates.index', $data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ class ZoneController extends Controller
|
|||
'countries' => CountryRepo::all(),
|
||||
];
|
||||
|
||||
$data = hook_filter('admin.zone.index.data', $data);
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
return json_success(trans('common.success'), $data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue