Files
portal-api/app/View/Components/Module/Datacenter.php
T
2025-07-24 16:18:27 +07:00

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'));
}
}