44 lines
1012 B
PHP
44 lines
1012 B
PHP
<?php
|
|
|
|
namespace App\View\Components\Module;
|
|
|
|
use App\Repositories\Module\Datacenter\DatacenterRepositoryInterface;
|
|
use Closure;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\View\Component;
|
|
|
|
class Datacenter extends Component
|
|
{
|
|
/**
|
|
* Create a new component instance.
|
|
*/
|
|
public function __construct(
|
|
public $model = null,
|
|
public DatacenterRepositoryInterface $datacenterRepository
|
|
)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Get the view / contents that represent the component.
|
|
*/
|
|
public function render(): View|Closure|string
|
|
{
|
|
$vcenterId = $this->model?->vCenter?->id;
|
|
|
|
$datacenters = null;
|
|
|
|
if ($vcenterId) {
|
|
$datacenters = $this->datacenterRepository->filter(
|
|
['vcenter_id' => $vcenterId],
|
|
[],
|
|
[],
|
|
['id', 'name']
|
|
);
|
|
}
|
|
|
|
return view('components.module.datacenter', compact('datacenters'));
|
|
}
|
|
}
|