my-idlers/app/Http/Controllers/OsController.php
cp6 3bd9d5890c Updated all destroy() methods
Updated all destroy() methods to directly delete the resource rather than fetch from database which turns out is not needed
2022-11-08 11:14:07 +11:00

48 lines
965 B
PHP

<?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()
{
$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
]);
Cache::forget('operating_systems');
return redirect()->route('os.index')
->with('success', 'OS Created Successfully.');
}
public function destroy(OS $o)
{
$o->delete();
Cache::forget('operating_systems');
return redirect()->route('os.index')
->with('success', 'OS was deleted Successfully.');
}
}