Enabled Domain homepage
This commit is contained in:
@@ -20,12 +20,13 @@ class DomainController extends Controller
|
||||
{
|
||||
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',
|
||||
'name' => 'required|max:8|unique:domains,name,'.$o->id,
|
||||
'dnsdomain' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i|unique:domains,dnsdomain,'.$o->id,
|
||||
'active' => 'required',
|
||||
'public' => 'required',
|
||||
]);
|
||||
|
||||
foreach (['name','dnsdomain','active','notes'] as $key)
|
||||
foreach (['name','dnsdomain','active','public','homepage','notes'] as $key)
|
||||
$o->{$key} = $request->post($key);
|
||||
|
||||
$o->save();
|
||||
|
@@ -2,12 +2,13 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Domain;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function network(string $name)
|
||||
public function network(Domain $o)
|
||||
{
|
||||
return view('networks')
|
||||
->with('content',$name)
|
||||
->with('network',$name);
|
||||
return view('domain.view')
|
||||
->with('o',$o);
|
||||
}
|
||||
}
|
@@ -10,10 +10,32 @@ class Domain extends Model
|
||||
{
|
||||
use ScopeActive;
|
||||
|
||||
/* SCOPES */
|
||||
|
||||
/**
|
||||
* Only query active records
|
||||
*/
|
||||
public function scopePublic($query)
|
||||
{
|
||||
return $query->where('public',TRUE);
|
||||
}
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
public function zones()
|
||||
{
|
||||
return $this->hasMany(Zone::class);
|
||||
}
|
||||
|
||||
/* CASTS */
|
||||
|
||||
public function getHomePageAttribute($value)
|
||||
{
|
||||
return $value ? gzuncompress(base64_decode($value)) : 'No available information at the moment.';
|
||||
}
|
||||
|
||||
public function setHomePageAttribute($value)
|
||||
{
|
||||
$this->attributes['homepage'] = base64_encode(gzcompress($value,9));
|
||||
}
|
||||
}
|
@@ -17,13 +17,5 @@ class Zone extends Model
|
||||
return $this->belongsTo(Domain::class);
|
||||
}
|
||||
|
||||
/* SCOPES */
|
||||
|
||||
/**
|
||||
* Only query active records
|
||||
*/
|
||||
public function scopePublic()
|
||||
{
|
||||
return $this->where('public',TRUE);
|
||||
}
|
||||
}
|
@@ -10,8 +10,8 @@ trait ScopeActive
|
||||
/**
|
||||
* Only query active records
|
||||
*/
|
||||
public function scopeActive()
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $this->where($this->getTable().'.active',TRUE);
|
||||
return $query->where($this->getTable().'.active',TRUE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user