<?php

namespace App\Admin\Controllers;

use App\Models\Article;
use App\Models\Category;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;

class ArticleController extends AdminController
{

    protected $title = '内容管理';

    public function grid()
    {
        $grid = new Grid(new Article);
        $grid->column('id', '#ID#');
        $grid->column('title', '文章标题');
        $grid->column('sort', '序号');
        $grid->column('created_at', '创建时间');

        return $grid;
    }

    public function form()
    {
        $form = new Form(new Article);

        $form->text('title', '文章标题');
        $form->number('category_id', '分类ID')
             ->help('审阅文件固定写 2 ');
        $form->textarea('desc');
        $form->ueditor('content', '文章内容')->rules('required', ['required' => '详情不能为空']);
        $form->number('sort', '序号')->default(0)->rules('required', ['required' => '序号必须填写'])->help('倒序优先');

        return $form;
    }

}
