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

49 lines
1.2 KiB
PHP

<?php
namespace App\View\Components\Module;
use App\Repositories\Module\Host\HostRepositoryInterface;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class Host extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public $model = null,
public HostRepositoryInterface $hostRepository
)
{
//
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
$hosts = null;
if(
$this->model &&
(
isset($this->model->ipaddress->host->module_datacenter_id) ||
isset($this->model->host->module_datacenter_id)
)
)
{
$hosts = $this->hostRepository->filter(
[
'module_datacenter_id' => $this->model->ipaddress->host->module_datacenter_id ?? $this->model->host->module_datacenter_id
],
[],
[],
['id', 'name']
);
}
return view('components.module.host',compact('hosts'));
}
}