2022-02-19 13:42:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\OS;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class OsController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$os = OS::all();
|
|
|
|
return view('os.index', compact(['os']));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function create()
|
|
|
|
{
|
|
|
|
return view('os.create');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
|
|
|
$request->validate([
|
2022-02-19 13:57:48 +01:00
|
|
|
'os_name' => 'required|min:2'
|
2022-02-19 13:42:59 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
OS::create([
|
|
|
|
'name' => $request->os_name
|
|
|
|
]);
|
|
|
|
|
|
|
|
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-02-19 13:57:48 +01:00
|
|
|
$items = OS::find($o->id);
|
2022-02-19 13:42:59 +01:00
|
|
|
|
|
|
|
$items->delete();
|
|
|
|
|
|
|
|
return redirect()->route('os.index')
|
|
|
|
->with('success', 'OS was deleted Successfully.');
|
|
|
|
}
|
|
|
|
}
|