54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\View\Components\Module;
|
|
|
|
use App\Repositories\Os\OsRepositoryInterface;
|
|
use Closure;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\View\Component;
|
|
|
|
class OsVersion extends Component
|
|
{
|
|
/**
|
|
* Create a new component instance.
|
|
*/
|
|
public function __construct(
|
|
public OsRepositoryInterface $osRepositoryInterface,
|
|
public $model = null,
|
|
public $os = null
|
|
)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Get the view / contents that represent the component.
|
|
*/
|
|
public function render(): View|Closure|string
|
|
{
|
|
$os_versions = null;
|
|
if($this->model && isset($this->model->os_id))
|
|
{
|
|
// First get the current OS to find its group
|
|
$currentOs = $this->osRepositoryInterface->find($this->model->os_id);
|
|
if($currentOs && $currentOs->os_group_id) {
|
|
// Then get all OS versions in the same group
|
|
$os_versions = $this->osRepositoryInterface->filter(
|
|
[
|
|
'os_group_id' => $currentOs->os_group_id
|
|
],
|
|
[],
|
|
[],
|
|
['id', 'version']
|
|
);
|
|
}
|
|
}
|
|
|
|
return view('components.module.os-version', [
|
|
'os_versions' => $os_versions,
|
|
'os' => $this->os,
|
|
'model' => $this->model
|
|
]);
|
|
}
|
|
}
|