mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-16 23:42:32 +01:00
Fixed OS cache
Fixed OS cache
This commit is contained in:
parent
06a3d71222
commit
6da3af1364
@ -230,7 +230,7 @@ class ApiController extends Controller
|
||||
|
||||
protected function getAllOs()
|
||||
{
|
||||
$os = OS::all()->toJson(JSON_PRETTY_PRINT);
|
||||
$os = OS::allOS()->toJson(JSON_PRETTY_PRINT);
|
||||
return response($os, 200);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ class OsController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$os = OS::all();
|
||||
$os = OS::allOS();
|
||||
return view('os.index', compact(['os']));
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ class OsController extends Controller
|
||||
'name' => $request->os_name
|
||||
]);
|
||||
|
||||
Cache::forget('all_os');
|
||||
Cache::forget('operating_systems');
|
||||
|
||||
return redirect()->route('os.index')
|
||||
->with('success', 'OS Created Successfully.');
|
||||
@ -41,7 +41,7 @@ class OsController extends Controller
|
||||
|
||||
$items->delete();
|
||||
|
||||
Cache::forget('all_os');
|
||||
Cache::forget('operating_systems');
|
||||
|
||||
return redirect()->route('os.index')
|
||||
->with('success', 'OS was deleted Successfully.');
|
||||
|
@ -83,7 +83,7 @@ class ServerController extends Controller
|
||||
{
|
||||
$Providers = Providers::all();
|
||||
$Locations = Locations::all();
|
||||
$Os = OS::all();
|
||||
$Os = OS::allOS();
|
||||
return view('servers.create', compact(['Providers', 'Locations', 'Os']));
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class OS extends Model
|
||||
{
|
||||
@ -12,4 +14,11 @@ class OS extends Model
|
||||
protected $fillable = ['name'];
|
||||
|
||||
protected $table = 'os';
|
||||
|
||||
public static function allOS(): array
|
||||
{
|
||||
return Cache::remember("operating_systems", now()->addMonth(1), function () {
|
||||
return DB::table('os')->get()->toArray();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,8 @@ 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
|
||||
'os' => OS::allOS()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
<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 value="{{ $o->id }}" {{(isset($current) && (string)$current === (string)$o->id)? 'selected' : ''}}>
|
||||
{{ $o->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
Loading…
Reference in New Issue
Block a user