<?php

namespace Modules\Mall\Http\Controllers\Admin;

use App\Admin\Traits\WithUploads;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Modules\Mall\Models\Activity;

class ActivityController extends AdminController
{

    use WithUploads;

    public $title = "活动列表";

    protected function grid(): Grid
    {
        $grid = new Grid(new Activity());

        $grid->disableFilter();


        $grid->column('id', '#ID#');
        $grid->column('title', '活动名称');
        $grid->column('description', '简介');
        $grid->column('status', '状态')->switch();
        $grid->column('created_at', '创建时间');

        return $grid;
    }

    protected function form(): Form
    {
        $form = new Form(new Activity());

        $form->text('title', '活动名称');
        $this->cover($form);
        $form->textarea('description', '简介');
        $form->ueditor('content', '详情')->required();

        $form->switch('status', '状态')->default(1);

        return $form;
    }

}
