<?php

namespace Modules\User\Http\Controllers\Admin;

use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Modules\User\Models\SmsGateway;

class GatewayController extends AdminController
{

    protected $title = '短信网关';

    public function grid(): Grid
    {
        $grid = new Grid(new SmsGateway());
        $grid->disableFilter();

        $grid->column('name', '网关名称');
        $grid->column('slug', '网关标识');
        $grid->column('created_at', '创建时间');

        return $grid;
    }

    public function form(): Form
    {
        $form = new Form(new SmsGateway());

        $form->text('name', '网关名称')->required();
        $form->text('slug', '网关标识')->required();
        $form->keyValue('configs', '网关配置')->value([
            'APP_ID'     => '',
            'APP_SECRET' => '',
            'SIGN_NAME'  => '',
        ]);

        return $form;
    }

}