<?php

namespace App\Nova\Resources\Ecommerce\Product\Product\Concerns\Variant;

use App\Repositories\Ecommerce\Product\Property\PropertyRepository;
use Ebess\AdvancedNovaMediaLibrary\Fields\Images;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;

class VariantFieldsForIndex
{
    /**
     * Get the fields for create.
     */
    public static function make(NovaRequest $request, $resource): array
    {
        return [
            ID::make()->sortable(),

            Images::make(__('Image'), 'uploads')
                ->conversionOnIndexView('thumb200x200'),

            Text::make(__('Price'), 'cost_amount')
                ->rules('required', 'numeric'),

            Text::make(__('Color'), fn () => PropertyRepository::getRealValue('colour', $resource->colour)),
            Text::make(__('Size'), fn () => PropertyRepository::getRealValue('size', $resource->size)),

            Number::make(__('Stock'), 'stock')
                ->rules('required', 'integer'),
        ];
    }
}
