12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- /*
- * This file is part of the Jiannei/lumen-api-starter.
- *
- * (c) Jiannei <longjian.huang@foxmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace App\Http\Controllers\Admin\Base;
- use App\Http\Controllers\Controller;
- use App\Repositories\Models\Base\Department;
- use Illuminate\Support\Facades\Cache;
- use Jiannei\Response\Laravel\Support\Facades\Response;
- class CommonController extends Controller
- {
- /**
- * 枚举类型
- * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\Resource
- * Author: Mead
- */
- public function enums()
- {
- $data = trans('enums');
- $enums = [];
- foreach ($data as $key => $val) {
- $k = last(str2arr($key, '\\'));
- $enums[$k] = $val;
- }
- return Response::success($enums);
- }
- /**
- * 清空缓存
- * @return mixed
- * Author: Mead
- */
- public function clear()
- {
- Cache::flush();
- return Response::noContent();
- }
- /**
- * 部门列表
- * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\Resource
- */
- public function departmentTree()
- {
- $departments = Department::query()->orderByDesc('sort')->select(['id', 'name', 'parent_id', 'sort', 'status'])->get()->append('parent_name')->toArray();
- return Response::success(toTree($departments));
- }
- }
|