107 lines
3.8 KiB
PHP
107 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use App\Models\Producer;
|
|
use App\Models\Product;
|
|
use App\Models\ProductGroup;
|
|
use App\Models\Supplier;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Concerns\InteractsWithForms;
|
|
use Filament\Forms\Contracts\HasForms;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Pages\Page;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class CurrentPrice extends Page implements HasForms
|
|
{
|
|
use InteractsWithForms;
|
|
|
|
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-currency-dollar';
|
|
|
|
protected static ?string $title = 'Aktuális ár';
|
|
|
|
protected static ?string $navigationLabel = 'Aktuális ár';
|
|
|
|
protected static string | \UnitEnum | null $navigationGroup = 'Statisztika';
|
|
|
|
public function getHeading(): string|\Illuminate\Contracts\Support\Htmlable
|
|
{
|
|
return '';
|
|
}
|
|
|
|
public function getBreadcrumbs(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
protected string $view = 'filament.pages.current-price';
|
|
|
|
public ?array $data = [];
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->form->fill();
|
|
}
|
|
|
|
public function form(Schema $form): Schema
|
|
{
|
|
return $form
|
|
->schema([
|
|
Select::make('supplier')
|
|
->label('Beszállító:')
|
|
->options(Supplier::orderBy('name')->pluck('name', 'id'))
|
|
->multiple()
|
|
->searchable()
|
|
->placeholder('Válasszon beszállítót...'),
|
|
Select::make('productGroup')
|
|
->label('Termékcsoport:')
|
|
->options(ProductGroup::orderBy('name')->pluck('name', 'id'))
|
|
->multiple()
|
|
->searchable()
|
|
->placeholder('Válasszon termékcsoportot...'),
|
|
Select::make('product')
|
|
->label('Termék:')
|
|
->multiple()
|
|
->searchable()
|
|
->getSearchResultsUsing(function (string $search, ?array $state) {
|
|
$query = Product::where('name', 'like', "%{$search}%");
|
|
return $query->limit(50)->pluck('name', 'name')->toArray();
|
|
})
|
|
->getOptionLabelsUsing(fn (array $values): array => Product::whereIn('name', $values)
|
|
->pluck('name', 'name')
|
|
->toArray())
|
|
->placeholder('Válasszon terméket...'),
|
|
Select::make('hooreycaName')
|
|
->label('Hooreyca megnevezés :')
|
|
->options(function () {
|
|
DB::statement("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));");
|
|
$options = Product::orderBy('buyerProductName')
|
|
->where('buyerProductName', '!=', '')
|
|
->groupBy('buyerProductName')
|
|
->pluck('buyerProductName', 'buyerProductName')
|
|
->toArray();
|
|
DB::statement("SET sql_mode=(SELECT CONCAT(@@sql_mode, ',ONLY_FULL_GROUP_BY'));");
|
|
return $options;
|
|
})
|
|
->multiple()
|
|
->searchable()
|
|
->placeholder('Válasszon megnevezést...'),
|
|
Select::make('producer')
|
|
->label('Gyártó :')
|
|
->options(Producer::orderBy('name')->pluck('name', 'id'))
|
|
->multiple()
|
|
->searchable()
|
|
->placeholder('Válasszon gyártót...'),
|
|
])
|
|
->statePath('data');
|
|
}
|
|
|
|
public function submit(): void
|
|
{
|
|
$data = $this->form->getState();
|
|
// Itt lehet majd feldolgozni a szűrést
|
|
// dd($data);
|
|
}
|
|
}
|