<?php

namespace App\Admin\Controllers;

use App\Models\Notice;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class NoticeController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Notice(), function (Grid $grid) {
            $grid->column('teacher_id')->using(config('map.teachers'));
            $grid->column('content');
            $grid->column('created_at');
            $grid->column('status')->using(config('map.notice_status'));
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new Notice(), function (Show $show) {
            $show->field('id');
            $show->field('teacher_id');
            $show->field('content');
            $show->field('created_at');
            $show->field('status');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Notice(), function (Form $form) {
            $form->text('teacher_id');
            $form->text('content');
            $form->text('status');
            $form->text('title');
            $form->text('desc');
            $form->text('photos');
            $form->text('pdf_file');
        });
    }
}
