<?php

namespace Modules\Mall\Http\Controllers\Admin;

use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Modules\Mall\Models\Job;

class JobController extends AdminController
{

    use WithShop;

    protected $title = '职位管理';

    public function grid(): Grid
    {
        $grid = new Grid(new Job());

        $grid->filter(function (Grid\Filter $filter) {
            $filter->column(1 / 2, function (Grid\Filter $filter) {
                $filter->like('shop.name', '所属店铺');
            });
            $filter->column(1 / 2, function (Grid\Filter $filter) {
                $filter->like('name', '职位名称');
            });
        });

        $grid->column('shop.name', '所属店铺');
        $grid->column('name', '职位名称');
        $grid->column('created_at', '创建时间');

        return $grid;
    }

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

        $this->shop($form)->required();
        $form->text('name', '职位名称')->required();

        return $form;
    }

}