mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-18 00:13:12 +01:00
adb589c60a
Updated OsController
45 lines
860 B
PHP
45 lines
860 B
PHP
<?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([
|
|
'os_name' => 'required|min:2'
|
|
]);
|
|
|
|
OS::create([
|
|
'name' => $request->os_name
|
|
]);
|
|
|
|
return redirect()->route('os.index')
|
|
->with('success', 'OS Created Successfully.');
|
|
}
|
|
|
|
public function destroy(OS $o)
|
|
{
|
|
$items = OS::find($o->id);
|
|
|
|
$items->delete();
|
|
|
|
return redirect()->route('os.index')
|
|
->with('success', 'OS was deleted Successfully.');
|
|
}
|
|
}
|