admin form add hook
optimize brands Optimize page and category hook
This commit is contained in:
parent
a75d795098
commit
024a2190f2
|
|
@ -44,10 +44,14 @@ 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);
|
||||
$requestData = $request->all();
|
||||
$data = [
|
||||
'request_data' => $requestData,
|
||||
];
|
||||
|
||||
hook_action('admin.brand.store.before', $data);
|
||||
$brand = BrandRepo::create($requestData);
|
||||
hook_action('admin.brand.store.after', ['brand' => $brand, 'request_data' => $requestData]);
|
||||
|
||||
return json_success(trans('common.created_success'), $brand);
|
||||
}
|
||||
|
|
@ -58,13 +62,13 @@ class BrandController extends Controller
|
|||
public function update(Request $request, int $id): array
|
||||
{
|
||||
$requestData = $request->all();
|
||||
$beforeData = [
|
||||
'brand_id' => $id,
|
||||
'data' => $requestData,
|
||||
$data = [
|
||||
'brand_id' => $id,
|
||||
'request_data' => $requestData,
|
||||
];
|
||||
hook_action('admin.brand.update.before', $beforeData);
|
||||
$brand = BrandRepo::update($id, $request->all());
|
||||
hook_action('admin.brand.update.after', $brand);
|
||||
hook_action('admin.brand.update.before', $data);
|
||||
$brand = BrandRepo::update($id, $requestData);
|
||||
hook_action('admin.brand.update.after', $data);
|
||||
|
||||
return json_success(trans('common.updated_success'), $brand);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,12 +58,11 @@ class PageCategoryController extends Controller
|
|||
public function store(PageCategoryRequest $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$requestData = $request->all();
|
||||
hook_action('admin.page_category.store.before', $requestData);
|
||||
$pageCategory = PageCategoryRepo::createOrUpdate($requestData);
|
||||
|
||||
hook_action('admin.page_category.store.after', $pageCategory);
|
||||
hook_action('admin.page_category.store.after', ['page_category' => $pageCategory, 'request_data' => $requestData]);
|
||||
|
||||
return redirect(admin_route('page_categories.index'));
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -105,7 +104,7 @@ class PageCategoryController extends Controller
|
|||
$requestData['id'] = $pageCategory->id;
|
||||
hook_action('admin.page_category.update.before', $requestData);
|
||||
$pageCategory = PageCategoryRepo::createOrUpdate($requestData);
|
||||
hook_action('admin.page_category.store.after', $pageCategory);
|
||||
hook_action('admin.page_category.update.after', ['page_category' => $pageCategory, 'request_data' => $requestData]);
|
||||
|
||||
return redirect()->to(admin_route('page_categories.index'));
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ class PagesController extends Controller
|
|||
{
|
||||
try {
|
||||
$requestData = $request->all();
|
||||
PageRepo::createOrUpdate($requestData);
|
||||
$page = PageRepo::createOrUpdate($requestData);
|
||||
hook_action('admin.page.store.after', ['request_data' => $requestData, 'page' => $page]);
|
||||
|
||||
return redirect(admin_route('pages.index'));
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -95,7 +96,8 @@ class PagesController extends Controller
|
|||
try {
|
||||
$requestData = $request->all();
|
||||
$requestData['id'] = $pageId;
|
||||
PageRepo::createOrUpdate($requestData);
|
||||
$page = PageRepo::createOrUpdate($requestData);
|
||||
hook_action('admin.page.update.after', ['request_data' => $requestData, 'page' => $page]);
|
||||
|
||||
return redirect()->to(admin_route('pages.index'));
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@
|
|||
@close="closeDialog('form')" :close-on-click-modal="false">
|
||||
|
||||
<el-form ref="form" :rules="rules" :model="dialog.form" label-width="100px">
|
||||
@hook('admin.brand.form.before')
|
||||
|
||||
<el-form-item label="{{ __('brand.name') }}" prop="name">
|
||||
<el-input class="mb-0" v-model="dialog.form.name" placeholder="{{ __('brand.name') }}"></el-input>
|
||||
</el-form-item>
|
||||
|
|
@ -66,6 +68,8 @@
|
|||
<el-input class="mb-0" type="number" v-model="dialog.form.sort_order" placeholder="{{ __('common.sort_order') }}"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
@hook('admin.brand.form.after')
|
||||
|
||||
<el-form-item label="{{ __('common.status') }}">
|
||||
<el-switch v-model="dialog.form.status" :active-value="1" :inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
<x-admin-alert type="success" msg="{{ session('success') }}" class="mt-4"/>
|
||||
@endif
|
||||
|
||||
@hook('admin.category.form.before')
|
||||
|
||||
<x-admin-form-input-locale name="descriptions.*.name" title="{{ __('common.name') }}" :value="$descriptions" :required="true" />
|
||||
<x-admin-form-input-locale name="descriptions.*.content" title="{{ __('admin/builder.modules_content') }}" :value="$descriptions" />
|
||||
|
||||
|
|
@ -60,6 +62,8 @@
|
|||
@endforeach
|
||||
</x-admin::form.row>
|
||||
|
||||
@hook('admin.category.form.after')
|
||||
|
||||
<x-admin-form-switch title="{{ __('common.status') }}" name="active" :value="old('active', $category->active ?? 1)" />
|
||||
|
||||
<x-admin::form.row>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#tab-content" type="button" >{{ __('admin/product.basic_information') }}</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#tab-set" type="button">{{ __('common.data') }}</button>
|
||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#tab-data" type="button">{{ __('common.data') }}</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
|
@ -66,7 +66,9 @@
|
|||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="tab-set">
|
||||
<div class="tab-pane fade" id="tab-data">
|
||||
@hook('admin.page_category.data.before')
|
||||
|
||||
<x-admin::form.row title="{{ __('admin/category.parent_category') }}">
|
||||
<div class="wp-400" id="app">
|
||||
<el-autocomplete
|
||||
|
|
@ -83,6 +85,9 @@
|
|||
</div>
|
||||
</x-admin::form.row>
|
||||
<x-admin-form-input name="position" title="{{ __('common.sort_order') }}" value="{{ old('position', $page_category->position ?? 0) }}" />
|
||||
|
||||
@hook('admin.page_category.data.after')
|
||||
|
||||
<x-admin-form-switch name="active" title="{{ __('common.status') }}" value="{{ old('active', $page_category->active ?? 1) }}" />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#tab-content" type="button" >{{ __('admin/product.basic_information') }}</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#tab-set" type="button">{{ __('common.data') }}</button>
|
||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#tab-data" type="button">{{ __('common.data') }}</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
|
@ -80,7 +80,9 @@
|
|||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="tab-set">
|
||||
<div class="tab-pane fade" id="tab-data">
|
||||
@hook('admin.page.data.before')
|
||||
|
||||
<x-admin-form-input name="author" title="{{ __('page_category.author') }}" value="{{ old('author', $page->author ?? '') }}" />
|
||||
<x-admin::form.row title="{{ __('admin/page_category.index') }}">
|
||||
<div class="wp-400">
|
||||
|
|
@ -135,8 +137,9 @@
|
|||
</div>
|
||||
</x-admin::form.row>
|
||||
|
||||
<x-admin-form-switch name="active" title="{{ __('common.status') }}" value="{{ old('active', $page->active ?? 1) }}" />
|
||||
@hook('admin.page.data.after')
|
||||
|
||||
<x-admin-form-switch name="active" title="{{ __('common.status') }}" value="{{ old('active', $page->active ?? 1) }}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -350,6 +350,9 @@
|
|||
|
||||
<div class="tab-pane fade" id="tab-seo">
|
||||
<h6 class="border-bottom pb-3 mb-4">SEO</h6>
|
||||
|
||||
@hook('admin.product.seo.before')
|
||||
|
||||
<x-admin-form-input-locale :width="600" name="descriptions.*.meta_title" title="Meta title" :value="$descriptions"/>
|
||||
<x-admin::form.row title="Meta keywords">
|
||||
@foreach ($languages as $language)
|
||||
|
|
@ -367,6 +370,8 @@
|
|||
</div>
|
||||
@endforeach
|
||||
</x-admin::form.row>
|
||||
|
||||
@hook('admin.product.seo.after')
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="tab-relations">
|
||||
|
|
|
|||
Loading…
Reference in New Issue