2022-02-19 13:42:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\OS;
|
|
|
|
use Illuminate\Http\Request;
|
2022-03-05 14:54:24 +01:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2022-02-19 13:42:59 +01:00
|
|
|
|
|
|
|
class OsController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
2022-05-09 06:57:38 +02:00
|
|
|
$os = OS::allOS();
|
2022-02-19 13:42:59 +01:00
|
|
|
return view('os.index', compact(['os']));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function create()
|
|
|
|
{
|
|
|
|
return view('os.create');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
|
|
|
$request->validate([
|
2022-11-08 00:39:05 +01:00
|
|
|
'os_name' => 'required|string|min:2|max:255'
|
2022-02-19 13:42:59 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
OS::create([
|
|
|
|
'name' => $request->os_name
|
|
|
|
]);
|
|
|
|
|
2022-05-09 06:57:38 +02:00
|
|
|
Cache::forget('operating_systems');
|
2022-03-05 14:54:24 +01:00
|
|
|
|
2022-02-19 13:42:59 +01:00
|
|
|
return redirect()->route('os.index')
|
|
|
|
->with('success', 'OS Created Successfully.');
|
|
|
|
}
|
|
|
|
|
2022-02-19 13:57:48 +01:00
|
|
|
public function destroy(OS $o)
|
2022-02-19 13:42:59 +01:00
|
|
|
{
|
2022-11-09 05:18:25 +01:00
|
|
|
if ($o->delete()) {
|
|
|
|
Cache::forget('operating_systems');
|
2022-02-19 13:42:59 +01:00
|
|
|
|
2022-11-09 05:18:25 +01:00
|
|
|
return redirect()->route('os.index')
|
|
|
|
->with('success', 'OS was deleted Successfully.');
|
|
|
|
}
|
2022-03-05 14:54:24 +01:00
|
|
|
|
2022-02-19 13:42:59 +01:00
|
|
|
return redirect()->route('os.index')
|
2022-11-09 05:18:25 +01:00
|
|
|
->with('error', 'OS was not deleted.');
|
|
|
|
|
2022-02-19 13:42:59 +01:00
|
|
|
}
|
|
|
|
}
|