form->getState()['production_order'] ?? '') ?? null; $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null; if (empty($plantId)) { Notification::make() ->title('Plant name cannot be empty!') ->danger() ->send(); return; } elseif (empty($pOrder)) { Notification::make() ->title('Production order cannot be empty!') ->danger() ->send(); return; } $pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first(); if (! $pOrderExists) { Notification::make() ->title("Production Order '{$pOrder}' does not exist to get print!") ->danger() ->send(); return; } else { return redirect()->route('production-orders.print', ['production_order' => $pOrder]); } } public function printPanel() { $plantId = $this->form->getState()['plant_id'] ?? null; $plantId = filled($plantId) ? (int) $plantId : null; $pOrder = $this->form->getState()['production_order'] ?? null; $pOrder = filled($pOrder) ? trim($pOrder) : null; $plantCode = Plant::where('id', $plantId)->value('code'); if (empty($plantId)) { Notification::make() ->title('Plant name cannot be empty!') ->danger() ->send(); return; } elseif (empty($pOrder)) { Notification::make() ->title('Production order cannot be empty!') ->danger() ->send(); return; } $pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first(); if (! $pOrderExists) { Notification::make() ->title("Production Order '{$pOrder}' does not exist to get print!") ->danger() ->send(); return; } else { return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]); } } protected function getHeaderActions(): array { return [ Actions\EditAction::make(), ]; } }