<?php

namespace App\Admin\Controllers\ServicePacksManagment;

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

class InsuranceAgreementController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '保险协议列表';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new InsuranceAgreement());
        $grid->disableBatchActions();
        $grid->actions(function ($actions){
           $actions->disableView();
        });
        $grid->column('id', __('Id'));
        $grid->column('name', __('协议名称'));
        $grid->column('content', __('协议内容'))->limit(20,'...');
        $status = [
            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
        ];
        $grid->column('status', __('状态'))->switch($status);
        $grid->column('created_at', __('创建时间'));
        $grid->column('updated_at', __('更新时间'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */

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

        $form->text('name', __('协议名称'));
        $form->editor('content', __('协议内容'));
        $status = [
            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
        ];
        $form->switch('status', __('状态'))->states($status)->default(1);

        return $form;
    }
}
