<?php

namespace App\Nova\Resources\System\VersionManagement;

use App\Models\System\Settings\OS;
use App\Models\System\VersionManagement\AppVersion as AppVersionModel;
use App\Nova\Resource;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;

class AppVersion extends Resource
{
    /**
     * The model the resource corresponds to.
     *
     * @var class-string<AppVersionModel>
     */
    public static $model = AppVersionModel::class;

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'version';

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = [
        'version',
    ];

    /**
     * Get the displayable label of the resource.
     */
    public static function label(): string
    {
        return __('App Versions');
    }

    /**
     * Get the displayable singular label of the resource.
     */
    public static function singularLabel(): string
    {
        return __('App Version');
    }

    /**
     * Get the fields displayed by the resource.
     */
    public function fields(NovaRequest $request): array
    {
        return [
            ID::make()->sortable(),

            Text::make(__('Version'), 'version')
                ->rules('required', 'string', 'max:255')
                ->sortable(),

            Select::make(__('Operating System'), 'os')
                ->displayUsingLabels()
                ->searchable()
                ->options(OS::types())
                ->rules('required', 'string', 'max:255')
                ->sortable(),

            Boolean::make(__('Important'), 'important')
                ->default(false)
                ->rules('required')
                ->sortable(),

            Text::make(__('Notes'), 'notes'),
        ];
    }

    /**
     * Get the cards available for the request.
     *
     * @return array
     */
    public function cards(NovaRequest $request)
    {
        return [];
    }

    /**
     * Get the filters available for the resource.
     *
     * @return array
     */
    public function filters(NovaRequest $request)
    {
        return [];
    }

    /**
     * Get the lenses available for the resource.
     *
     * @return array
     */
    public function lenses(NovaRequest $request)
    {
        return [];
    }

    /**
     * Get the actions available for the resource.
     *
     * @return array
     */
    public function actions(NovaRequest $request)
    {
        return [];
    }
}
