<?php

namespace App\Admin\Controllers\UserManagement\BmUser;

use App\Models\Feedback;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class FeedBacksController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '反馈列表';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Feedback());
        $grid->actions(function ($actions){
           $actions->disableView();
           $actions->disableEdit();
        });
        $grid->filter(function ($filter){
           $filter->like('docter.nickname','名字');
        });
        $grid->column('id', __('Id'));
        $grid->column('user_id', __('用户id'));
        $grid->column('docter.nickname', __('用户名字'));
        $grid->column('docter.phone', __('用户手机号'));
        $grid->column('content', __('反馈内容'))->limit(50,'...');
        $grid->column('created_at', __('创建时间'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(Feedback::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('user_id', __('User id'));
        $show->field('content', __('Content'));
        $show->field('created_at', __('Created at'));
        $show->field('updated_at', __('Updated at'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Feedback());

        $form->number('user_id', __('User id'));
        $form->text('content', __('Content'));

        return $form;
    }
}
