<?php

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

use Encore\Admin\Grid\Selectable;
use Modules\Mall\Models\Reason;

class Reasons extends Selectable
{

    public $model = Reason::class;

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

    public static function display()
    {
        return function ($value) {
            if (is_array($value)) {
                return implode(';', array_column($value, 'title'));
            }

            return optional($this->reaons)->name;
        };
    }

}
