Skip to content

Commit

Permalink
✨(update): 前端菜单节点路由名唯一判断
Browse files Browse the repository at this point in the history
  • Loading branch information
Joycezhangw committed Feb 21, 2023
1 parent fc47450 commit 382687c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/Http/Controllers/Manage/V1/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,22 @@ public function read(int $id, MenuRepo $menuRepo)
return $this->success($menuRepo->parseDataRow($menu->toArray()));
}


/**
* 新增菜单
* @param MenuRequest $request
* @param MenuRepo $menuRepo
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Contracts\Container\BindingResolutionException
* @throws \JoyceZ\LaravelLib\Exceptions\RepositoryException
*/
public function store(MenuRequest $request, MenuRepo $menuRepo)
{
$params = $request->all();
$params['parent_id'] = trim((string)$params['parent_id']) == '' ? 0 : $params['parent_id'];

$menu = $menuRepo->existsWhere(['menu_name' => $params['menu_name']]);
if ($menu) {
return $this->badSuccessRequest('节点路由名已存在');
}
$menuRepo->transaction();
try {
if ($menuRepo->create($params)) {
Expand Down

0 comments on commit 382687c

Please sign in to comment.