2021-05-13 12:40:21 +00:00
|
|
|
<?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()) {
|
2021-06-14 05:46:18 +00:00
|
|
|
$request->validate([
|
2021-06-17 14:08:30 +00:00
|
|
|
'name' => 'required|max:8|unique:domains,name,'.($o->exists ? $o->id : 0),
|
|
|
|
'dnsdomain' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i|unique:domains,dnsdomain,'.($o->exists ? $o->id : NULL),
|
2021-06-14 05:46:18 +00:00
|
|
|
'active' => 'required',
|
2021-06-14 11:33:18 +00:00
|
|
|
'public' => 'required',
|
2021-06-14 05:46:18 +00:00
|
|
|
]);
|
|
|
|
|
2021-06-14 11:33:18 +00:00
|
|
|
foreach (['name','dnsdomain','active','public','homepage','notes'] as $key)
|
2021-05-13 12:40:21 +00:00
|
|
|
$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');
|
|
|
|
}
|
|
|
|
}
|