Update source into github
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?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
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user