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};
|
2021-05-03 12:12:26 +00:00
|
|
|
|
2019-04-26 04:30:00 +00:00
|
|
|
class Zone extends Model
|
|
|
|
{
|
2022-01-20 06:51:40 +00:00
|
|
|
use ScopeActive;
|
2021-05-03 12:12:26 +00:00
|
|
|
|
2021-06-24 12:28:06 +00:00
|
|
|
/* SCOPES */
|
|
|
|
|
|
|
|
public function scopeDomainZoneOrder($query)
|
|
|
|
{
|
|
|
|
return $query
|
2021-06-25 06:42:12 +00:00
|
|
|
->select('zones.*')
|
2021-06-24 12:28:06 +00:00
|
|
|
->join('domains',['domains.id'=>'zones.domain_id'])
|
|
|
|
->orderBy('domains.name')
|
|
|
|
->orderBy('zone_id');
|
|
|
|
}
|
|
|
|
|
2021-05-13 12:40:21 +00:00
|
|
|
/* RELATIONS */
|
|
|
|
|
2021-06-20 13:03:20 +00:00
|
|
|
public function addresses()
|
|
|
|
{
|
2021-07-26 11:21:58 +00:00
|
|
|
return $this->hasMany(Address::class)
|
|
|
|
->active()
|
|
|
|
->FTNorder()
|
|
|
|
->with(['system.sessions','system.setup','zone.domain']);
|
2021-06-20 13:03:20 +00:00
|
|
|
}
|
|
|
|
|
2021-05-13 12:40:21 +00:00
|
|
|
public function domain()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Domain::class);
|
|
|
|
}
|
|
|
|
|
2021-06-19 01:59:01 +00:00
|
|
|
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
|
|
|
}
|