Update source into github
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Repositories\Module\Datacenter\DatacenterRepositoryInterface;
|
||||
use App\Repositories\vCenter\vCenterRepositoryInterface;
|
||||
use Livewire\Component;
|
||||
|
||||
class VcenterDatacenterSelect extends Component
|
||||
{
|
||||
public $vcenter_id;
|
||||
public $datacenter_id;
|
||||
public $vcenters = [];
|
||||
public $datacenters = [];
|
||||
|
||||
protected $vCenterRepository;
|
||||
protected $datacenterRepository;
|
||||
|
||||
public function boot(
|
||||
vCenterRepositoryInterface $vCenterRepository,
|
||||
DatacenterRepositoryInterface $datacenterRepository
|
||||
)
|
||||
{
|
||||
$this->vCenterRepository = $vCenterRepository;
|
||||
$this->datacenterRepository = $datacenterRepository;
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->vcenters = $this->vCenterRepository->filter(['status' => 1], [], [], ['id', 'host']);
|
||||
}
|
||||
|
||||
public function updatedVcenterId($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
$this->datacenters = $this->datacenterRepository->filter(
|
||||
['vcenter_id' => $value],
|
||||
[],
|
||||
[],
|
||||
['id', 'name']
|
||||
);
|
||||
} else {
|
||||
$this->datacenters = [];
|
||||
}
|
||||
$this->datacenter_id = null; // reset datacenter nếu vcenter đổi
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.vcenter-datacenter-select',
|
||||
[
|
||||
'vcenters' => $this->vcenters
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user