<?php

namespace Modules\Vrc\Http\Controllers\Registers;

use Modules\Vrc\Entities\VrcStorageBin;

class StorageBinController extends AbstractRegisterController
{
    protected function schema(): array
    {
        $locations = $this->locations();

        return [
            'key' => 'storage_bins',
            'route' => 'vrc.storage-bins',
            'model' => VrcStorageBin::class,
            'permView' => 'vrc.storage.view',
            'permManage' => 'vrc.storage.manage',
            'title' => 'Parts Storage Bins',
            'singular' => 'Storage Bin',
            'modalSize' => 'modal',
            'defaults' => ['is_active' => true],
            'columns' => [
                ['key' => 'code', 'label' => 'Code'],
                ['key' => 'zone', 'label' => 'Zone'],
                ['key' => 'rack', 'label' => 'Rack'],
                ['key' => 'shelf', 'label' => 'Shelf'],
                ['key' => 'location_id', 'label' => 'Location', 'map' => $locations],
                ['key' => 'is_active', 'label' => 'Active', 'map' => [1 => 'Active', 0 => 'Inactive'], 'badge' => [1 => 'success', 0 => 'default'], 'noSort' => true],
            ],
            'fields' => [
                ['name' => 'code', 'label' => 'Bin code', 'type' => 'text', 'required' => true, 'col' => 4, 'max' => 60],
                ['name' => 'location_id', 'label' => 'Location', 'type' => 'select', 'options' => $locations, 'col' => 4],
                ['name' => 'zone', 'label' => 'Zone', 'type' => 'text', 'col' => 4, 'max' => 60],
                ['name' => 'rack', 'label' => 'Rack', 'type' => 'text', 'col' => 4, 'max' => 60],
                ['name' => 'shelf', 'label' => 'Shelf', 'type' => 'text', 'col' => 4, 'max' => 60],
                ['name' => 'description', 'label' => 'Description', 'type' => 'text', 'col' => 4, 'max' => 191],
                ['name' => 'is_active', 'label' => 'Active', 'type' => 'checkbox', 'col' => 12, 'default' => true],
            ],
        ];
    }
}
