Added System, fixed something with Domain, added 403, start of some other items

This commit is contained in:
Deon George
2021-06-18 00:08:30 +10:00
parent 1e7c05cb90
commit 491d3d55c3
17 changed files with 451 additions and 16 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\System;
class SystemController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Add or edit a node
*/
public function add_edit(Request $request,System $o)
{
if ($request->post()) {
$request->validate([
'name' => 'required|min:3|unique:systems,name,'.($o->exists ? $o->id : 0),
'location' => 'required|min:3',
'sysop' => 'required|min:3',
'address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
'port' => 'nullable|digits_between:2,5',
]);
foreach (['name','location','sysop','address','port','active','method','notes'] as $key)
$o->{$key} = $request->post($key);
$o->save();
return redirect()->action([self::class,'home']);
}
return view('system.addedit')
->with('o',$o);
}
public function home()
{
return view('system.home');
}
}