You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
929 B
PHP
42 lines
929 B
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\Customer;
|
|
use Illuminate\Support\Collection;
|
|
use Livewire\Component;
|
|
|
|
class CustomerAndContactSelect extends Component
|
|
{
|
|
public Collection $customers;
|
|
|
|
public Collection $contacts;
|
|
|
|
public string $selectedCustomer;
|
|
|
|
public function mount(Collection $customers)
|
|
{
|
|
$this->customers = $customers;
|
|
|
|
if (isset($this->selectedCustomer)) {
|
|
$this->contacts = Customer::find($this->selectedCustomer)->contacts;
|
|
} else {
|
|
$this->contacts = $customers->first()->contacts;
|
|
}
|
|
|
|
}
|
|
|
|
public function updateContactList()
|
|
{
|
|
$this->contacts = Customer::find($this->selectedCustomer)->contacts;
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.customer-and-contact-select', [
|
|
'customers' => $this->customers,
|
|
'contacts' => $this->contacts,
|
|
]);
|
|
}
|
|
}
|