supplierId = $first->supplier_id; $this->profitCenterId = $first->profit_center_id; } } public function getSuppliers(): array { return Supplier::orderBy('name')->pluck('name', 'id')->toArray(); } public function getProfitCenters(): array { if (!$this->supplierId) { return ProfitCenter::orderBy('name')->pluck('name', 'id')->toArray(); } $pcIds = ProfitCenterSupplierSchedule::where('supplier_id', $this->supplierId) ->pluck('profit_center_id'); return ProfitCenter::whereIn('id', $pcIds)->orderBy('name')->pluck('name', 'id')->toArray(); } public function updatedSupplierId(): void { $this->profitCenterId = null; $first = ProfitCenterSupplierSchedule::where('supplier_id', $this->supplierId)->first(); if ($first) { $this->profitCenterId = $first->profit_center_id; } $this->dispatch('calendar-filter-changed', supplierId: $this->supplierId, profitCenterId: $this->profitCenterId); } public function updatedProfitCenterId(): void { $this->dispatch('calendar-filter-changed', supplierId: $this->supplierId, profitCenterId: $this->profitCenterId); } }