Files
pds/app/Filament/Pages/Dashboard.php
2025-04-24 10:27:00 +05:30

63 lines
1.6 KiB
PHP

<?php
namespace App\Filament\Pages;
use App\Filament\Widgets\CumulativeChart;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Tables\Filters\SelectFilter;
use Illuminate\Support\Facades\DB;
use App\Models\Plant;
use Filament\Widgets\Widget;
use Illuminate\Support\Facades\Auth;
class Dashboard extends \Filament\Pages\Dashboard
{
use HasFiltersForm;
protected static ?string $navigationGroup = 'Production DashBoard';
public function mount(): void
{
session()->forget(['selected_plant']);
$this->filtersForm->fill([
'plant' => null
]);
}
public function filtersForm(Form $form): Form
{
return $form
->statePath('filters') // Store form state in 'filters'
->schema([
Select::make('plant')
->options(Plant::pluck('name', 'id'))
->label('Select Plant')
->reactive()
->afterStateUpdated(function ($state) {
session(['selected_plant' => $state]); // fixed typo
$this->dispatch('cumulativeChart'); // custom Livewire event
}),
]);
}
public static function getNavigationLabel(): string
{
return 'Production Line Count';
}
public function getHeading(): string
{
return 'Production Line Count';
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production line count dashboard');
}
}