<?php

namespace App\Admin\Controllers;

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

class TakebackEntrustmentController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new TakebackEntrustment(), function (Grid $grid) {
            
            $grid->column('student_id')->using(config('map.students'));
            $grid->column('entrust_time');
            $grid->column('take_back_person')->using(config('map.parent_ids'));
            $grid->column('take_back_desc');
            $grid->column('take_back_photos');
            $grid->column('sign');
           
        
            $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 TakebackEntrustment(), function (Show $show) {
            $show->field('id');
            $show->field('student_id');
            $show->field('entrust_time');
            $show->field('take_back_person');
            $show->field('take_back_desc');
            $show->field('take_back_photos');
            $show->field('sign');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new TakebackEntrustment(), function (Form $form) {
         
            $form->text('student_id');
            $form->text('entrust_time');
            $form->text('take_back_person');
            $form->text('take_back_desc');
            $form->text('take_back_photos');
            $form->text('sign');

        });
    }
}
