From 9ddb71f03dc5a1f856fdfef3825095e5e6db867a Mon Sep 17 00:00:00 2001 From: Jp Date: Mon, 16 Feb 2026 02:06:59 +0800 Subject: [PATCH] feat(SaleResource): redirect to client after sale creation When a client is associated with the sale, redirect to the client's view page with the sales relation manager active instead of the default list page. This improves the user workflow by keeping the context focused on the client. --- app/Filament/Resources/SaleResource/Pages/CreateSale.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/SaleResource/Pages/CreateSale.php b/app/Filament/Resources/SaleResource/Pages/CreateSale.php index b6f063f..ec4fcb7 100644 --- a/app/Filament/Resources/SaleResource/Pages/CreateSale.php +++ b/app/Filament/Resources/SaleResource/Pages/CreateSale.php @@ -89,8 +89,12 @@ class CreateSale extends CreateRecord return $record; } - protected function afterCreate(): void + protected function getRedirectUrl(): string { - $branch = Branch::find($this->data['branch_id']); + $client = $this->getClient(); + if (! $client) { + return parent::getRedirectUrl(); + } + return ClientResource::getUrl('view', ['record' => $client->id]).'?activeRelationManager=3'; } }