<?php

namespace App\Nova\Resources\System\Payments;

use App\Models\System\Settings\Payments\PaymentType as PaymentTypeModel;
use App\Nova\Resource;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Trin4ik\NovaSwitcher\NovaSwitcher;

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

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

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

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

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

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

            Text::make(__('Name'), 'name')
                ->translatable()
                ->rules('required', 'string', 'max:255'),

            Text::make(__('Tax'), 'tax')
                ->rules('nullable', 'string', 'max:255'),

            NovaSwitcher::make(__('Is enabled'), 'is_enabled')
                ->default(true),
        ];
    }
}
