<?php

namespace Modules\Mall\Http\Controllers\Admin\Selectable;

use Encore\Admin\Grid\Filter;
use Encore\Admin\Grid\Selectable;
use Modules\Mall\Models\Express;

class Expresses extends Selectable
{
    public $model = Express::class;

    public function make()
    {
        $this->column('id', '#ID#');
        $this->column('name', '物流名称');
        $this->column('status', '状态')->bool();
        $this->column('created_at', '时间');

        $this->filter(function (Filter $filter) {
            $filter->like('name', '物流名称');
        });
    }

    public static function display()
    {
        return function ($value) {
            if (is_array($value)) {
                return implode(';', array_column($value, 'name'));
            }
            return optional($this->expresses)->name;
        };
    }
}
