<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\PromptTask;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class PromptTaskController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new PromptTask(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('prompt');
            $grid->column('user_id');
            $grid->column('task_id');
            $grid->column('prompt_img');
            $grid->column('result_img');
            $grid->column('type');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
        
            $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 PromptTask(), function (Show $show) {
            $show->field('id');
            $show->field('prompt');
            $show->field('user_id');
            $show->field('task_id');
            $show->field('prompt_img');
            $show->field('result_img');
            $show->field('type');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new PromptTask(), function (Form $form) {
            $form->display('id');
            $form->text('prompt');
            $form->text('user_id');
            $form->text('task_id');
            $form->text('prompt_img');
            $form->text('result_img');
            $form->text('type');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
