<?php
 namespace App\Http\Controllers\Admin; use TechOnline\Laravel\Dao\ModelUtil; use TechSoft\Laravel\Admin\Cms\BasicCms; use TechSoft\Laravel\Admin\Cms\Field\FieldEmpty; use TechSoft\Laravel\Admin\Cms\Field\FieldRichtext; use TechSoft\Laravel\Admin\Support\AdminCheckController; class NoteCommentController extends AdminCheckController { protected $cmsConfigBasic = [ 'model' => 'note_comment', 'pageTitle' => '文章评论', 'group' => 'data', 'canAdd' => false, 'canEdit' => false, 'canDelete' => true, 'fields' => [ '_note' => ['type' => FieldEmpty::class, 'title' => '文章', 'list' => true, 'edit' => true, 'add' => true,], 'content' => ['type' => FieldRichtext::class, 'title' => '内容', 'list' => true, 'edit' => true, 'add' => true,], ] ]; public function dataPostAdd(&$data) { } public function dataPostEdit(&$data) { } public function dataPostDelete(&$data) { ModelUtil::delete('comment_like', ['commentId' => $data['id']]); ModelUtil::delete('note_comment', ['rootCommentId' => $data['id']]); } public function dataProcessViewField($key, &$record) { switch ($key) { case '_note': $note = ModelUtil::get('note', ['id' => $record['noteId']]); return '<a href="/n/' . $note['alias'] . '" target="_blank">' . htmlspecialchars($note['title']) . '</a>'; } } public function dataProcessView(&$item, &$record) { $item['content'] = '<div class="html-container">' . $record['content'] . '</div>'; } 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); } }