livewire clients form updated

This commit is contained in:
Thekindbull 2025-06-11 11:37:05 +08:00
parent 517957ca5b
commit 6f63bd9118

View File

@ -44,8 +44,7 @@ protected function rules()
} }
public function mount() public function mount()
{ {
$userBroker = Agent::where('user_id', auth()->user()->id)->first(); $agent = Agent::where('user_id', auth()->user()->id)->first();
$this->complexes = Complex::where('city_id', $userBroker->company->city_id)->get();
$this->client = [ $this->client = [
'firstName' => '', 'firstName' => '',
'secondName' => '', 'secondName' => '',
@ -53,13 +52,21 @@ public function mount()
'complexId' => '' 'complexId' => ''
]; ];
$this->status = self::NEW; $this->status = self::NEW;
if ($agent = Agent::where('user_id', auth()->user()->id)->first())
if ($agent)
{ {
$this->agent = $agent->id; $this->agent = $agent->id;
$this->complexes = Complex::where('city_id', $agent->company->city_id)->get();
} }
else else
{ {
$this->agent = false; $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() public function update()