增加 setting hook

This commit is contained in:
Edward Yang 2023-02-07 15:07:28 +08:00
parent 72a385efbb
commit c60e32b401
3 changed files with 57 additions and 14 deletions

View File

@ -114,7 +114,7 @@ class Sidebar extends Component
{
$prefix = ['home.'];
return hook_filter('sidebar.home.prefix', $prefix);
return hook_filter('admin.sidebar.home.prefix', $prefix);
}
/**
@ -124,7 +124,7 @@ class Sidebar extends Component
{
$prefix = ['products.', 'categories.', 'brands.', 'attribute_groups.', 'attributes.'];
return hook_filter('sidebar.product.prefix', $prefix);
return hook_filter('admin.sidebar.product.prefix', $prefix);
}
/**
@ -134,7 +134,7 @@ class Sidebar extends Component
{
$prefix = ['customers.', 'customer_groups.'];
return hook_filter('sidebar.customer.prefix', $prefix);
return hook_filter('admin.sidebar.customer.prefix', $prefix);
}
/**
@ -144,7 +144,7 @@ class Sidebar extends Component
{
$prefix = ['orders.', 'rmas.', 'rma_reasons.'];
return hook_filter('sidebar.order.prefix', $prefix);
return hook_filter('admin.sidebar.order.prefix', $prefix);
}
/**
@ -154,7 +154,7 @@ class Sidebar extends Component
{
$prefix = ['pages.'];
return hook_filter('sidebar.page.prefix', $prefix);
return hook_filter('admin.sidebar.page.prefix', $prefix);
}
/**
@ -164,7 +164,7 @@ class Sidebar extends Component
{
$prefix = ['settings.', 'admin_users.', 'admin_roles.', 'plugins.', 'marketing.', 'tax_classes', 'tax_rates', 'regions', 'currencies', 'languages', 'design_menu', 'countries', 'zones'];
return hook_filter('sidebar.setting.prefix', $prefix);
return hook_filter('admin.sidebar.setting.prefix', $prefix);
}
/**
@ -181,7 +181,7 @@ class Sidebar extends Component
['route' => 'plugins.index', 'icon' => 'fa fa-tachometer-alt', 'hide_mobile' => 1],
];
return hook_filter('sidebar.home_routes', $routes);
return hook_filter('admin.sidebar.home_routes', $routes);
}
/**
@ -198,7 +198,7 @@ class Sidebar extends Component
['route' => 'products.trashed', 'icon' => 'fa fa-tachometer-alt'],
];
return hook_filter('sidebar.product_routes', $routes);
return hook_filter('admin.sidebar.product_routes', $routes);
}
/**
@ -212,7 +212,7 @@ class Sidebar extends Component
['route' => 'customers.trashed', 'icon' => 'fa fa-tachometer-alt'],
];
return hook_filter('sidebar.customer_routes', $routes);
return hook_filter('admin.sidebar.customer_routes', $routes);
}
/**
@ -226,7 +226,7 @@ class Sidebar extends Component
['route' => 'rma_reasons.index', 'icon' => 'fa fa-tachometer-alt'],
];
return hook_filter('sidebar.order_routes', $routes);
return hook_filter('admin.sidebar.order_routes', $routes);
}
/**
@ -239,7 +239,7 @@ class Sidebar extends Component
['route' => 'pages.index', 'icon' => 'fa fa-tachometer-alt'],
];
return hook_filter('sidebar.pages_routes', $routes);
return hook_filter('admin.sidebar.pages_routes', $routes);
}
/**
@ -265,7 +265,7 @@ class Sidebar extends Component
['route' => 'design_menu.index', 'icon' => 'fa fa-tachometer-alt', 'hide_mobile' => 1],
];
return hook_filter('sidebar.setting_routes', $routes);
return hook_filter('admin.sidebar.setting_routes', $routes);
}
/**

View File

@ -24,6 +24,7 @@ class Bootstrap
// $this->modifyProductDetail();
// $this->modifyAdminProductEdit();
// $this->modifySetting();
}
@ -81,13 +82,12 @@ class Bootstrap
{
// 通过数据 hook 修改产品详情页产品名称
add_hook_filter('product.show.data', function ($product) {
$product['product']['name'] = '[疯狂热销]'. $product['product']['name'];
$product['product']['name'] = '[疯狂热销]' . $product['product']['name'];
return $product;
});
// 通过模板 hook 在产品详情页名称上面添加 Hot 标签
add_hook_blade('product.detail.name', function ($callback, $output, $data) {
return $output;
$badge = '<span class="badge" style="background-color: #FF4D00; color: #ffffff; border-color: #FF4D00">Hot</span>';
return $badge . $output;
});
@ -116,4 +116,19 @@ class Bootstrap
}, 1);
}
/**
* 系统设置添加新 tab
*/
private function modifySetting()
{
add_hook_blade('admin.setting.nav.after', function ($callback, $output, $data) {
return view('LatestProducts::admin.setting.nav')->render();
});
add_hook_blade('admin.setting.after', function ($callback, $output, $data) {
return view('LatestProducts::admin.setting.tab')->render();
});
}
}

View File

@ -26,18 +26,26 @@
<li class="nav-item" role="presentation">
<a class="nav-link" data-bs-toggle="tab" href="#tab-mail">{{ __('admin/setting.mail_settings') }}</a>
</li>
@hook('admin.setting.nav.after')
</ul>
<div class="tab-content">
<div class="tab-pane fade show active" id="tab-general">
@hook('admin.setting.general.before')
<x-admin-form-input name="meta_title" title="{{ __('admin/setting.meta_title') }}" value="{{ old('meta_title', system_setting('base.meta_title', '')) }}" />
<x-admin-form-textarea name="meta_description" title="{{ __('admin/setting.meta_description') }}" value="{{ old('meta_description', system_setting('base.meta_description', '')) }}" />
<x-admin-form-textarea name="meta_keywords" title="{{ __('admin/setting.meta_keywords') }}" value="{{ old('meta_keywords', system_setting('base.meta_keywords', '')) }}" />
<x-admin-form-input name="telephone" title="{{ __('admin/setting.telephone') }}" value="{{ old('telephone', system_setting('base.telephone', '')) }}" />
<x-admin-form-input name="email" title="{{ __('admin/setting.email') }}" value="{{ old('email', system_setting('base.email', '')) }}" />
@hook('admin.setting.general.after')
</div>
<div class="tab-pane fade" id="tab-store">
@hook('admin.setting.store.before')
<x-admin-form-switch name="guest_checkout" title="{{ __('admin/setting.guest_checkout') }}" value="{{ old('guest_checkout', system_setting('base.guest_checkout', '1')) }}">
</x-admin-form-switch>
@ -95,9 +103,15 @@
<x-admin-form-textarea name="head_code" title="{{ __('admin/setting.head_code') }}" value="{!! old('head_code', system_setting('base.head_code', '')) !!}">
<div class="help-text font-size-12 lh-base">{{ __('admin/setting.head_code_info') }}</div>
</x-admin-form-textarea>
@hook('admin.setting.store.after')
</div>
<div class="tab-pane fade" id="tab-image">
@hook('admin.setting.image.before')
<x-admin-form-image name="logo" title="logo" :value="old('logo', system_setting('base.logo', ''))">
<div class="help-text font-size-12 lh-base">{{ __('common.recommend_size') }} 380*100</div>
</x-admin-form-image>
@ -109,9 +123,13 @@
<x-admin-form-image name="placeholder" title="{{ __('admin/setting.placeholder_image') }}" :value="old('placeholder', system_setting('base.placeholder', ''))">
<div class="help-text font-size-12 lh-base">{{ __('admin/setting.placeholder_image_info') }}</div>
</x-admin-form-image>
@hook('admin.setting.image.after')
</div>
<div class="tab-pane fade" id="tab-express-company">
@hook('admin.setting.express.before')
<x-admin::form.row title="{{ __('order.express_company') }}">
<table class="table table-bordered w-max-600">
<thead>
@ -138,9 +156,13 @@
</tbody>
</table>
</x-admin::form.row>
@hook('admin.setting.express.after')
</div>
<div class="tab-pane fade" id="tab-mail">
@hook('admin.setting.mail.before')
<x-admin-form-switch name="use_queue" title="{{ __('admin/setting.use_queue') }}" value="{{ old('use_queue', system_setting('base.use_queue', '0')) }}">
{{-- <div class="help-text font-size-12 lh-base">{{ __('admin/setting.enable_tax_info') }}</div> --}}
</x-admin-form-switch>
@ -182,7 +204,13 @@
<x-admin-form-input name="mailgun[endpoint]" required title="{{ __('admin/setting.mailgun_endpoint') }}" value="{{ old('endpoint', system_setting('base.mailgun.endpoint', '')) }}">
</x-admin-form-input>
</div>
@hook('admin.setting.mail.after')
</div>
@hook('admin.setting.after')
</div>
<x-admin::form.row title="">