From 754c78f36505a644de9c3d12968a1deb8836c36b Mon Sep 17 00:00:00 2001 From: Alexander Gabriel Date: Thu, 26 Feb 2026 22:01:56 +0000 Subject: [PATCH] actions umgeschrieben --- app/Filament/Resources/Orders/Pages/EditOrder.php | 15 +++++++++------ .../Resources/Orders/Schemas/OrderForm.php | 10 +++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/Filament/Resources/Orders/Pages/EditOrder.php b/app/Filament/Resources/Orders/Pages/EditOrder.php index 68f248a..a369764 100644 --- a/app/Filament/Resources/Orders/Pages/EditOrder.php +++ b/app/Filament/Resources/Orders/Pages/EditOrder.php @@ -20,21 +20,24 @@ class EditOrder extends EditRecord Action::make('bestellt_single') ->icon(Heroicon::ShoppingCart)->label("Bestellt")->action(function(Model $record) { $orderstatusBestellt = Orderstatus::where("name", "bestellt")->first(); - $record->orderstatus_id = $orderstatusBestellt->id; + $record->orderstatus()->associate($orderstatusBestellt); $record->save(); - })->visible(function(Model $record) {$orderstatusErfasst = Orderstatus::where("name", "erfasst")->first();return ($orderstatusErfasst->id == $record->orderstatus_id);}), + $this->refreshFormData(['orderstatus_id']); + })->visible(function(Model $record) {return ($record->orderstatus->name == 'erfasst');}), Action::make('angekommen_single') ->icon(Heroicon::BuildingOffice)->label("Angekommen")->action(function(Model $record) { $orderstatusAngekommen = Orderstatus::where("name", "angekommen")->first(); - $record->orderstatus_id = $orderstatusAngekommen->id; + $record->orderstatus()->associate($orderstatusAngekommen); $record->save(); - })->visible(function(Model $record) {$orderstatusBestellt = Orderstatus::where("name", "bestellt")->first();return ($orderstatusBestellt->id == $record->orderstatus_id);}), + $this->refreshFormData(['orderstatus_id']); + })->visible(function(Model $record) {return ($record->orderstatus->name == 'bestellt');}), Action::make('genommen_single') ->icon(Heroicon::Check)->label("Genommen")->action(function(Model $record) { $orderstatusGenommen = Orderstatus::where("name", "genommen")->first(); - $record->orderstatus_id = $orderstatusGenommen->id; + $record->orderstatus()->associate($orderstatusGenommen); $record->save(); - })->visible(function(Model $record) {$orderstatusAngekommen = Orderstatus::where("name", "angekommen")->first();return ($orderstatusAngekommen->id == $record->orderstatus_id);}), + $this->refreshFormData(['orderstatus_id']); + })->visible(function(Model $record) {return ($record->orderstatus->name == 'angekommen');}), Action::make("url_oeffnen")->icon(Heroicon::Link)->label("URL öffnen")->url(function (Model $record) { return $record->url;}, true), DeleteAction::make(), ]; diff --git a/app/Filament/Resources/Orders/Schemas/OrderForm.php b/app/Filament/Resources/Orders/Schemas/OrderForm.php index 063bb3f..cf7a26e 100644 --- a/app/Filament/Resources/Orders/Schemas/OrderForm.php +++ b/app/Filament/Resources/Orders/Schemas/OrderForm.php @@ -2,6 +2,7 @@ namespace App\Filament\Resources\Orders\Schemas; +use App\Filament\Resources\Orders\OrderResource; use App\Models\Orderstatus; use Filament\Actions\Action; use Filament\Forms\Components\DateTimePicker; @@ -46,19 +47,22 @@ class OrderForm $orderstatusBestellt = Orderstatus::where("name", "bestellt")->first(); $record->orderstatus_id = $orderstatusBestellt->id; $record->save(); - })->visible(function(Model $record) {$orderstatusErfasst = Orderstatus::where("name", "erfasst")->first();return ($orderstatusErfasst->id == $record->orderstatus_id);}), + redirect(OrderResource::getUrl('edit', ['record' => $record->id,])); + })->visible(function(Model $record) {return ($record->orderstatus->name == 'erfasst');}), Action::make('angekommen_single') ->icon(Heroicon::BuildingOffice)->label("Angekommen")->action(function(Model $record) { $orderstatusAngekommen = Orderstatus::where("name", "angekommen")->first(); $record->orderstatus_id = $orderstatusAngekommen->id; $record->save(); - })->visible(function(Model $record) {$orderstatusBestellt = Orderstatus::where("name", "bestellt")->first();return ($orderstatusBestellt->id == $record->orderstatus_id);}), + redirect(OrderResource::getUrl('edit', ['record' => $record->id,])); + })->visible(function(Model $record) {return ($record->orderstatus->name == 'bestellt');}), Action::make('genommen_single') ->icon(Heroicon::Check)->label("Genommen")->action(function(Model $record) { $orderstatusGenommen = Orderstatus::where("name", "genommen")->first(); $record->orderstatus_id = $orderstatusGenommen->id; $record->save(); - })->visible(function(Model $record) {$orderstatusAngekommen = Orderstatus::where("name", "angekommen")->first();return ($orderstatusAngekommen->id == $record->orderstatus_id);}), + redirect(OrderResource::getUrl('edit', ['record' => $record->id,])); + })->visible(function(Model $record) {return ($record->orderstatus->name == 'angekommen');}), Action::make("url_oeffnen")->icon(Heroicon::Link)->label("URL öffnen")->url(function (Model $record) { return $record->url;}, true), ]), DateTimePicker::make('orderdatetime')