<?php
 namespace App\Http\Controllers\Admin; use TechOnline\Laravel\Dao\ModelUtil; use TechSoft\Laravel\Admin\Cms\BasicCms; use TechSoft\Laravel\Admin\Cms\Field\FieldSwitch; use TechSoft\Laravel\Admin\Cms\Field\FieldText; use TechSoft\Laravel\Admin\Support\AdminCheckController; class NoteController extends AdminCheckController { protected $cmsConfigBasic = [ 'model' => 'note', 'pageTitle' => '文章管理', 'group' => 'data', 'canAdd' => false, 'canEdit' => true, 'canDelete' => true, 'fields' => [ 'title' => ['type' => FieldText::class, 'title' => '标题', 'list' => true, 'edit' => true, 'add' => true, 'search' => true,], 'isRecommend' => ['type' => FieldSwitch::class, 'title' => '推荐', 'list' => true, 'edit' => true, 'add' => true,], ] ]; public function dataPostAdd(&$data) { } public function dataPostEdit(&$data) { } public function dataPostDelete(&$data) { ModelUtil::delete('note_like', ['noteId' => $data['id']]); ModelUtil::delete('note_comment', ['noteId' => $data['id']]); ModelUtil::delete('topic_note', ['noteId' => $data['id']]); ModelUtil::delete('topic_note_apply', ['noteId' => $data['id']]); } public function dataProcessView(&$item, &$record) { $item['title'] = '<a href="/n/' . $record['alias'] . '" target="_blank">' . $item['title'] . '</a>'; if ($record['isRecommend']) { $recommendAction = '<a href="javascript:;" data-uk-tooltip title="取消推荐" data-ajax-request-loading data-ajax-request="' . action('\App\Http\Controllers\Admin\NoteController@dataEdit', ['_action' => BasicCms::ACTION_QUICK_EDIT, '_id' => $record['id'], 'isRecommend' => false,]) . '"><i class="uk-icon-minus-circle"></i></a>'; } else { $recommendAction = '<a href="javascript:;" data-uk-tooltip title="设置推荐" data-ajax-request-loading data-ajax-request="' . action('\App\Http\Controllers\Admin\NoteController@dataEdit', ['_action' => BasicCms::ACTION_QUICK_EDIT, '_id' => $record['id'], 'isRecommend' => true,]) . '"><i class="uk-icon-check-circle"></i></a>'; } $item['isRecommend'] .= ' ' . $recommendAction; } public function dataList(BasicCms $basicCms) { return $basicCms->executeList($this, $this->cmsConfigBasic);; } public function dataDelete(BasicCms $basicCms) { return $basicCms->executeDelete($this, $this->cmsConfigBasic); } public function dataEdit(BasicCms $basicCms) { return $basicCms->executeEdit($this, $this->cmsConfigBasic); } public function dataAdd(BasicCms $basicCms) { return $basicCms->executeAdd($this, $this->cmsConfigBasic); } }