1
0
forked from poc/pds

Import Fun Completed and Sticker Master

This commit is contained in:
dhanabalan
2025-03-28 16:52:40 +05:30
parent ef4504155a
commit e46f290fd1
47 changed files with 1317 additions and 335 deletions

View File

@@ -1,33 +1,50 @@
<?php
namespace App\Filament\Pages;
use Filament\Forms\Form;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Pages\Dashboard as BaseDashboard;
use App\Models\Line;
use Filament\Tables\Filters\SelectFilter;
use Illuminate\Support\Facades\DB;
use App\Models\Plant;
class Dashboard extends BaseDashboard
class Dashboard extends \Filament\Pages\Dashboard
{
use HasFiltersForm;
use HasFiltersForm;
public function filtersForm(Form $form): Form
{
return $form->schema([
// Select::make('plant_id')
// ->relationship('plant', 'name')
// ->required()
// ->reactive(),
public function filtersForm(Form $form): Form
{
$selectedPlant = session('selected_plant', request()->input('filters.Plant'));
return $form->schema([
// Plant Filter
Select::make('Plant')
->options(Plant::pluck('name', 'id')) // Fetch plant names with their IDs
->label('Select Plant')
->reactive()
->afterStateUpdated(function ($state, callable $set) use ($selectedPlant) {
// Update only in memory and not in the URL
session(['selected_plant' => $state]); // Store in session
session()->forget('selected_line'); // Reset line filter
$set('Plant', $state);
$set('Line', null);
$this->dispatch('filtersUpdated'); // Notify chart to refresh
}),
// Line Filter
Select::make('Line')
->options(function ($get) {
$plantId = $get('Plant');
return $plantId ? Plant::find($plantId)->getLineNames()->pluck('name', 'id') : [];
})
->label('Select Line')
->reactive()
->afterStateUpdated(function ($state) {
session(['selected_line' => $state]); // Store in session
$this->dispatch('filtersUpdated'); // Notify chart to refresh
}),
]);
}
// Select::make('line_id')
// ->relationship('line', 'name')
// ->required()
// ->options(fn (callable $get) =>
// Line::where('plant_id', $get('plant_id'))->pluck('name', 'id')
// )
// ->reactive()
// ->afterStateUpdated(fn ($set) => $set('line_id', null)),
]);
}
}