clrghouz/app/Http/Controllers/DomainController.php

45 lines
841 B
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Domain;
class DomainController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Add or edit a node
*/
public function add_edit(Request $request,Domain $o)
{
if ($request->post()) {
$request->validate([
'name' => 'required|unique:domains|max:8',
'dnsdomain' => 'nullable|unique:domains|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
'active' => 'required',
]);
foreach (['name','dnsdomain','active','notes'] as $key)
$o->{$key} = $request->post($key);
$o->save();
return redirect()->action([self::class,'home']);
}
return view('domain.addedit')
->with('o',$o);
}
public function home()
{
return view('domain.home');
}
}