All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
75 lines
2.7 KiB
PHP
75 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use Filament\Pages\Page;
|
|
use Filament\Forms\Form;
|
|
use Filament\Forms\Components\Section;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Facades\Filament;
|
|
use App\Models\Plant;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class PanelBoxPalletCount extends Page
|
|
{
|
|
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
|
|
|
protected static string $view = 'filament.pages.panel-box-pallet-count';
|
|
|
|
protected static ?string $navigationGroup = 'Panel Box Pallet';
|
|
|
|
public array $filters = [];
|
|
|
|
public function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->statePath('filters')
|
|
->schema([
|
|
Section::make('')
|
|
->schema([
|
|
|
|
Select::make('plant_id')
|
|
->label('Plant')
|
|
->relationship('plant', 'name')
|
|
->reactive()
|
|
// ->searchable()
|
|
->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();
|
|
})
|
|
->required()
|
|
->afterStateUpdated(function ($state, callable $get, $set) {
|
|
$set('pallet_count', null);
|
|
}),
|
|
Select::make('pallet_count')
|
|
->label('Select Pallet')
|
|
->required()
|
|
->columnSpan(1)
|
|
->options(function (callable $get) {
|
|
|
|
if (!$get('plant_id')) {
|
|
return [];
|
|
}
|
|
|
|
return \App\Models\PanelPalletValidation::where('plant_id', $get('plant_id'))
|
|
->pluck('pallet_number', 'pallet_number')
|
|
->toArray();
|
|
})
|
|
->reactive()
|
|
->afterStateUpdated(function ($state, callable $get, $set) {
|
|
$plantId = $get('plant_id');
|
|
$this->dispatch('loadData',$state, $plantId);
|
|
}),
|
|
|
|
])
|
|
->columns(2)
|
|
]);
|
|
}
|
|
|
|
public static function canAccess(): bool
|
|
{
|
|
return Auth::check() && Auth::user()->can('view panel pallet count page');
|
|
}
|
|
}
|