1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace Modules\Video\Http\Controllers;
- use Catch\Base\CatchController;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\DB;
- class VideoCategoryController extends CatchController
- {
- /**
- * 视频分类
- * @param Request $request
- * @return array
- */
- public function list(Request $request) {
- $videoCategorys = DB::table('video_category')
- ->get();
- $pCategory = $videoCategorys->where('pid', '=', 0)->all();
- $data = [];
- foreach ($pCategory as $item) {
- $data[$item->id] = [
- 'value' => $item->id,
- 'label' => $item->category_name,
- ];
- }
- foreach ($videoCategorys->where('pid', '!=', 0)->all() as $item) {
- $data[$item->pid]['children'][] = [
- 'value' => $item->id, 'label' => $item->category_name,
- ];
- }
- return array_values($data);
- }
- }
|