<?php

namespace App\Filament\Supplier\Resources\ProductStocks;

use App\Filament\Supplier\Resources\ProductStocks\Pages\EditProductStock;
use App\Filament\Supplier\Resources\ProductStocks\Pages\ListProductStocks;
use App\Filament\Supplier\Resources\ProductStocks\Schemas\ProductStockForm;
use App\Filament\Supplier\Resources\ProductStocks\Tables\ProductStocksTable;
use App\Models\Product;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;

class ProductStockResource extends Resource
{
    protected static ?string $model = Product::class;

    protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCube;

    protected static ?string $navigationLabel = 'Termékeim';

    protected static ?string $breadcrumb = 'Termékeim';

    protected static ?string $modelLabel = 'Termék';

    protected static ?string $pluralLabel = 'Termékeim';

    /**
     * Csak a bejelentkezett supplier saját termékei jelennek meg.
     */
    public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()
            ->where('supplier_id', auth()->user()->supplier_id);
    }

    public static function form(Schema $schema): Schema
    {
        return ProductStockForm::configure($schema);
    }

    public static function table(Table $table): Table
    {
        return ProductStocksTable::configure($table);
    }

    public static function getPages(): array
    {
        return [
            'index' => ListProductStocks::route('/'),
            'edit'  => EditProductStock::route('/{record}/edit'),
        ];
    }
}
