clrghouz/app/Models/Zone.php

52 lines
878 B
PHP
Raw Normal View History

2019-04-26 04:30:00 +00:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
2022-01-01 05:59:35 +00:00
use App\Traits\{QueryCacheableConfig,ScopeActive};
2019-04-26 04:30:00 +00:00
class Zone extends Model
{
use ScopeActive;
/* SCOPES */
public function scopeDomainZoneOrder($query)
{
return $query
->select('zones.*')
->join('domains',['domains.id'=>'zones.domain_id'])
->orderBy('domains.name')
->orderBy('zone_id');
}
2021-05-13 12:40:21 +00:00
/* RELATIONS */
public function addresses()
{
return $this->hasMany(Address::class)
->active()
->FTNorder()
->with(['system.sessions','system.setup','zone.domain']);
}
2021-05-13 12:40:21 +00:00
public function domain()
{
return $this->belongsTo(Domain::class);
}
public function system()
{
return $this->belongsTo(System::class);
}
2021-08-09 13:35:22 +00:00
/**
* Get the default route for this zone
*/
public function systems()
{
return $this->belongsToMany(System::class)
->withPivot(['default']);
}
2019-04-26 04:30:00 +00:00
}