Created OS route and controller
Created OS route and controller
This commit is contained in:
parent
d5b5d46bd6
commit
2abdf25c45
44
app/Http/Controllers/OsController.php
Normal file
44
app/Http/Controllers/OsController.php
Normal 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.');
|
||||||
|
}
|
||||||
|
}
|
|
@ -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']);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user