<?php
 namespace App\Http\Controllers\Admin; use TechOnline\Laravel\Dao\ModelUtil; use TechOnline\Laravel\Http\Response; use TechSoft\Laravel\Admin\Cms\BasicCms; use TechSoft\Laravel\Admin\Cms\Field\FieldCategory; use TechSoft\Laravel\Admin\Cms\Field\FieldImage; use TechSoft\Laravel\Admin\Cms\Field\FieldText; use TechSoft\Laravel\Admin\Cms\Field\FieldTextarea; use TechSoft\Laravel\Admin\Support\AdminCheckController; class QuestionTagController extends AdminCheckController { private $cmsConfigData = [ 'model' => 'question_tag', 'pageTitle' => '题目标签', 'group' => 'data', 'canAdd' => true, 'canEdit' => true, 'canDelete' => true, 'canView' => true, 'canSort' => true, 'fields' => [ 'groupId' => ['type' => FieldCategory::class, 'title' => '标签组', 'list' => true, 'add' => true, 'edit' => true, 'view' => true, 'model' => 'question_tag_group'], 'title' => ['type' => FieldText::class, 'title' => '名称', 'list' => true, 'add' => true, 'edit' => true, 'view' => true], 'cover' => ['type' => FieldImage::class, 'title' => '图标', 'list' => true, 'add' => true, 'edit' => true, 'view' => true,], 'description' => ['type' => FieldTextarea::class, 'title' => '说明', 'add' => true, 'edit' => true, 'view' => true,], ] ]; public function map() { $tagGroupMap = ModelUtil::valueMap('question_tag_group', 'id', 'title'); $tagMap = array_build(ModelUtil::all('question_tag'), function ($k, $v) use ($tagGroupMap) { $name = $v['title']; if ($v['groupId']) { if (!empty($tagGroupMap[$v['groupId']])) { $name = $tagGroupMap[$v['groupId']] . '-' . $name; } } return [$name, $v['id']]; }); return Response::jsonSuccessData($tagMap); } public function dataList(BasicCms $basicCms) { return $basicCms->executeList($this, $this->cmsConfigData); } public function dataAdd(BasicCms $basicCms) { return $basicCms->executeAdd($this, $this->cmsConfigData); } public function dataEdit(BasicCms $basicCms) { return $basicCms->executeEdit($this, $this->cmsConfigData); } public function dataDelete(BasicCms $basicCms) { return $basicCms->executeDelete($this, $this->cmsConfigData); } public function dataView(BasicCms $basicCms) { return $basicCms->executeView($this, $this->cmsConfigData); } }