Created OS route and controller

Created OS route and controller
This commit is contained in:
cp6 2022-02-19 23:42:59 +11:00
parent d5b5d46bd6
commit 2abdf25c45
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,44 @@
<?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([
'name' => 'required|min:2'
]);
OS::create([
'name' => $request->os_name
]);
return redirect()->route('os.index')
->with('success', 'OS Created Successfully.');
}
public function destroy(OS $OS)
{
$items = OS::find($OS->id);
$items->delete();
return redirect()->route('os.index')
->with('success', 'OS was deleted Successfully.');
}
}

View File

@ -46,6 +46,8 @@ Route::resource('locations', LocationsController::class)->middleware(['auth']);
Route::resource('misc', MiscController::class)->middleware(['auth']); Route::resource('misc', MiscController::class)->middleware(['auth']);
Route::resource('os', OsController::class)->middleware(['auth']);
Route::resource('providers', ProvidersController::class)->middleware(['auth']); Route::resource('providers', ProvidersController::class)->middleware(['auth']);
Route::resource('reseller', ResellerController::class)->middleware(['auth']); Route::resource('reseller', ResellerController::class)->middleware(['auth']);