mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-16 15:33:44 +01:00
Added os select component
Added os select component
This commit is contained in:
parent
a7d0e07723
commit
a9adf342c0
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\OS;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class OsController extends Controller
|
||||
{
|
||||
@ -28,6 +29,8 @@ class OsController extends Controller
|
||||
'name' => $request->os_name
|
||||
]);
|
||||
|
||||
Cache::forget('all_os');
|
||||
|
||||
return redirect()->route('os.index')
|
||||
->with('success', 'OS Created Successfully.');
|
||||
}
|
||||
@ -38,6 +41,8 @@ class OsController extends Controller
|
||||
|
||||
$items->delete();
|
||||
|
||||
Cache::forget('all_os');
|
||||
|
||||
return redirect()->route('os.index')
|
||||
->with('success', 'OS was deleted Successfully.');
|
||||
}
|
||||
|
20
app/View/Components/OsSelect.php
Normal file
20
app/View/Components/OsSelect.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use App\Models\OS;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class OsSelect extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
$all_os = Cache::rememberForever('all_os', function () {
|
||||
return OS::all();
|
||||
});
|
||||
return view('components.os-select', [
|
||||
'os' => $all_os
|
||||
]);
|
||||
}
|
||||
}
|
10
resources/views/components/os-select.blade.php
Normal file
10
resources/views/components/os-select.blade.php
Normal file
@ -0,0 +1,10 @@
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend"><span class="input-group-text">{{ $title ??'OS'}}</span></div>
|
||||
<select class="form-control" name="{{$name ?? 'os_id'}}">
|
||||
@foreach ($os as $o)
|
||||
<option value="{{ $o['id'] }}" {{(isset($current) && (string)$current === (string)$o['id'])? 'selected' : ''}}>
|
||||
{{ $o['name'] }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user