添加权限和菜单
This commit is contained in:
parent
71489cc733
commit
474bac5955
|
|
@ -28,6 +28,10 @@ class ProductController extends Controller
|
|||
return view('admin::pages.products.index', $data);
|
||||
}
|
||||
|
||||
public function trashed(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
return $this->form($request, new Product());
|
||||
|
|
|
|||
|
|
@ -42,7 +42,10 @@ class PermissionRepo
|
|||
$permissions = [
|
||||
['title' => trans('admin/common.order'), 'permissions' => $this->getOrderPermissions()],
|
||||
['title' => trans('admin/common.product'), 'permissions' => $this->getProductPermissions()],
|
||||
['title' => trans('admin/common.category'), 'permissions' => $this->getCategoryPermissions()],
|
||||
['title' => trans('admin/common.brand'), 'permissions' => $this->getBrandPermissions()],
|
||||
['title' => trans('admin/common.customer'), 'permissions' => $this->getCustomerPermissions()],
|
||||
['title' => trans('admin/common.customer_group'), 'permissions' => $this->getCustomerGroupPermissions()],
|
||||
['title' => trans('admin/common.setting'), 'permissions' => $this->getSettingPermissions()],
|
||||
|
||||
['title' => trans('admin/common.plugin'), 'permissions' => $this->getPluginPermissions()],
|
||||
|
|
@ -76,12 +79,38 @@ class PermissionRepo
|
|||
*/
|
||||
private function getProductPermissions(): array
|
||||
{
|
||||
$routes = ['products_index', 'products_create', 'products_edit', 'products_update', 'products_delete'];
|
||||
$routes = ['products_index', 'products_create', 'products_edit', 'products_update', 'products_delete', 'products_trashed'];
|
||||
$items = $this->getPermissionList('product', $routes);
|
||||
return hook_filter('role.product_permissions', $items);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分类权限列表
|
||||
*
|
||||
* @return \string[][]
|
||||
*/
|
||||
private function getCategoryPermissions(): array
|
||||
{
|
||||
$routes = ['categories_index', 'categories_create', 'categories_edit', 'categories_update', 'categories_delete'];
|
||||
$items = $this->getPermissionList('category', $routes);
|
||||
return hook_filter('role.category_permissions', $items);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 品牌权限列表
|
||||
*
|
||||
* @return \string[][]
|
||||
*/
|
||||
private function getBrandPermissions(): array
|
||||
{
|
||||
$routes = ['brands_index', 'brands_create', 'brands_edit', 'brands_update', 'brands_delete'];
|
||||
$items = $this->getPermissionList('brand', $routes);
|
||||
return hook_filter('role.brand_permissions', $items);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 客户权限列表
|
||||
*
|
||||
|
|
@ -95,6 +124,19 @@ class PermissionRepo
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 客户组权限列表
|
||||
*
|
||||
* @return \string[][]
|
||||
*/
|
||||
private function getCustomerGroupPermissions(): array
|
||||
{
|
||||
$routes = ['customer_groups_index', 'customer_groups_create', 'customer_groups_edit', 'customer_groups_update', 'customer_groups_delete'];
|
||||
$items = $this->getPermissionList('customer_group', $routes);
|
||||
return hook_filter('role.customer_group_permissions', $items);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置权限列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ Route::prefix($adminName)
|
|||
Route::post('plugins/{code}/uninstall', [Controllers\PluginController::class, 'uninstall'])->name('plugins.uninstall');
|
||||
|
||||
Route::put('products/restore', [Controllers\ProductController::class, 'restore']);
|
||||
Route::get('products/trashed', [Controllers\ProductController::class, 'trashed'])->name('products.trashed');
|
||||
Route::get('products/{id}/name', [Controllers\ProductController::class, 'name'])->name('products.name');
|
||||
Route::get('products/names', [Controllers\ProductController::class, 'getNames'])->name('products.names');
|
||||
Route::resource('products', Controllers\ProductController::class);
|
||||
|
|
|
|||
|
|
@ -114,6 +114,12 @@ class ProductRepo
|
|||
$builder->where('active', (int)$data['active']);
|
||||
}
|
||||
|
||||
// 回收站
|
||||
if (isset($data['trashed']) && $data['trashed']) {
|
||||
$builder->onlyTrashed();
|
||||
}
|
||||
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue