my-idlers/app/Http/Controllers/OsController.php

50 lines
1005 B
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers;
use App\Models\OS;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class OsController extends Controller
{
public function index()
{
2022-05-09 06:57:38 +02:00
$os = OS::allOS();
return view('os.index', compact(['os']));
}
public function create()
{
return view('os.create');
}
public function store(Request $request)
{
$request->validate([
'os_name' => 'required|string|min:2|max:255'
]);
OS::create([
'name' => $request->os_name
]);
2022-05-09 06:57:38 +02:00
Cache::forget('operating_systems');
return redirect()->route('os.index')
->with('success', 'OS Created Successfully.');
}
public function destroy(OS $o)
{
$items = OS::find($o->id);
$items->delete();
2022-05-09 06:57:38 +02:00
Cache::forget('operating_systems');
return redirect()->route('os.index')
->with('success', 'OS was deleted Successfully.');
}
}