Changed dashboard logic as welcome page in dashboard page
Some checks failed
Gemini PR Review / Gemini PR Review (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Waiting to run
Laravel Larastan / larastan (pull_request) Waiting to run
Laravel Pint / pint (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Gemini PR Review / Gemini PR Review (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Waiting to run
Laravel Larastan / larastan (pull_request) Waiting to run
Laravel Pint / pint (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\CumulativeChart;
|
||||
use App\Filament\Widgets\ProductionQuantityStat;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
@@ -9,64 +10,117 @@ use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Dashboard extends \Filament\Pages\Dashboard
|
||||
{
|
||||
use HasFiltersForm;
|
||||
use HasFiltersForm;
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
protected static ?string $navigationIcon = 'heroicon-s-gift';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null
|
||||
]);
|
||||
}
|
||||
protected static string $view = 'filament.pages.dashboard';
|
||||
|
||||
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 function mount(): void
|
||||
// {
|
||||
// session()->forget(['selected_plant']);
|
||||
// session()->forget(['from_date']);
|
||||
// session()->forget(['to_date']);
|
||||
// $this->filtersForm->fill([
|
||||
// 'plant' => null,
|
||||
// 'from_date' => null,
|
||||
// 'to_date' => null,
|
||||
// // 'success_status' => null
|
||||
// ]);
|
||||
// }
|
||||
|
||||
}
|
||||
// public function filtersForm(Form $form): Form
|
||||
// {
|
||||
// return $form
|
||||
// ->statePath('filters') // Store form state in 'filters'
|
||||
// ->schema([
|
||||
// Select::make('plant')
|
||||
// ->label('Select Plant')
|
||||
// ->reactive()
|
||||
// // ->options(Plant::pluck('name', 'id'))
|
||||
// ->options(function (callable $get) {
|
||||
// $userHas = Filament::auth()->user()->plant_id;
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
// })
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['selected_plant' => $state]); // fixed typo
|
||||
// //$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
// // Reset success_status whenever plant changes
|
||||
// $set('success_status', null);
|
||||
// session()->forget('success_status');
|
||||
// }),
|
||||
|
||||
// // Select::make('success_status')
|
||||
// // ->label('Select Status')
|
||||
// // ->options([
|
||||
// // 'Ok' => 'Ok',
|
||||
// // 'Not Ok' => 'Not Ok',
|
||||
// // ])
|
||||
// // ->reactive()
|
||||
// // ->afterStateUpdated(function ($state) {
|
||||
// // session(['success_status' => $state]);
|
||||
// // }),
|
||||
|
||||
// DatePicker::make('created_from')
|
||||
// ->label('Created From')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['from_date' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_to')
|
||||
// ->label('Created To')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['to_date' => $state]);
|
||||
// }),
|
||||
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
// public static function getNavigationLabel(): string
|
||||
// {
|
||||
// return 'Production Line Count';
|
||||
// }
|
||||
|
||||
// public function getHeading(): string
|
||||
// {
|
||||
// return 'Production Line Count';
|
||||
// }
|
||||
|
||||
// public function getWidgets(): array
|
||||
// {
|
||||
// $widgets = [];
|
||||
|
||||
// if (CumulativeChart::canView()) {
|
||||
// $widgets[] = CumulativeChart::class;
|
||||
|
||||
// }
|
||||
// return $widgets;
|
||||
// }
|
||||
|
||||
// public static function canAccess(): bool
|
||||
// {
|
||||
// return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
// }
|
||||
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
if (CumulativeChart::canView()) {
|
||||
$widgets[] = CumulativeChart::class;
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
return 'Welcome';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
use App\Filament\Widgets\CumulativeChart;
|
||||
use App\Filament\Widgets\ProductionQuantityStat;
|
||||
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\Facades\Filament;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
|
||||
class Welcome extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-s-gift'; // 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.welcome';
|
||||
|
||||
public function getHeading(): string
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
use InteractsWithForms;
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
protected static ?string $slug = 'production-line-count';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
return '';
|
||||
session()->forget(['selected_plant']);
|
||||
// session()->forget(['from_date']);
|
||||
// session()->forget(['to_date']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
// 'from_date' => null,
|
||||
// 'to_date' => null,
|
||||
// 'success_status' => null
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
// ->options(Plant::pluck('name', 'id'))
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state,callable $set) {
|
||||
session(['selected_plant' => $state]);
|
||||
//$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
// Reset success_status whenever plant changes
|
||||
// $set('success_status', null);
|
||||
// session()->forget('success_status');
|
||||
}),
|
||||
|
||||
// Select::make('success_status')
|
||||
// ->label('Select Status')
|
||||
// ->options([
|
||||
// 'Ok' => 'Ok',
|
||||
// 'Not Ok' => 'Not Ok',
|
||||
// ])
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state) {
|
||||
// session(['success_status' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_from')
|
||||
// ->label('Created From')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['from_date' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_to')
|
||||
// ->label('Created To')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['to_date' => $state]);
|
||||
// }),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
// public static function canAccess(): bool
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
// public function getWidgets(): array
|
||||
// {
|
||||
// return Auth::check() && Auth::user()->can('view welcome page');
|
||||
// $widgets = [];
|
||||
|
||||
// if (CumulativeChart::canView()) {
|
||||
// $widgets[] = CumulativeChart::class;
|
||||
|
||||
// }
|
||||
// return $widgets;
|
||||
// }
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user