From 6f63bd911824eebc7847ea160d6608fe55ae8195 Mon Sep 17 00:00:00 2001 From: Thekindbull Date: Wed, 11 Jun 2025 11:37:05 +0800 Subject: [PATCH] livewire clients form updated --- app/Livewire/CreateClientForm.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Livewire/CreateClientForm.php b/app/Livewire/CreateClientForm.php index 2efb830..64bb99f 100644 --- a/app/Livewire/CreateClientForm.php +++ b/app/Livewire/CreateClientForm.php @@ -44,8 +44,7 @@ protected function rules() } public function mount() { - $userBroker = Agent::where('user_id', auth()->user()->id)->first(); - $this->complexes = Complex::where('city_id', $userBroker->company->city_id)->get(); + $agent = Agent::where('user_id', auth()->user()->id)->first(); $this->client = [ 'firstName' => '', 'secondName' => '', @@ -53,13 +52,21 @@ public function mount() 'complexId' => '' ]; $this->status = self::NEW; - if ($agent = Agent::where('user_id', auth()->user()->id)->first()) + + if ($agent) { $this->agent = $agent->id; + $this->complexes = Complex::where('city_id', $agent->company->city_id)->get(); + } else { $this->agent = false; + $admin = CompanyAdmin::where('user_id', auth()->user()->id)->first(); + if ($admin) + { + $this->complexes = Complex::where('city_id', $admin->company_id)->get(); + } } } public function update()