clrghouz/app/Models/Zone.php
Deon George 3ad20f969b
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 37s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m41s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
Put back laravel-eloquent-query-cache and remove Caching from previous commit
2024-05-11 09:10:00 +10:00

52 lines
899 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Traits\{QueryCacheableConfig,ScopeActive};
class Zone extends Model
{
use QueryCacheableConfig,ScopeActive;
/* SCOPES */
public function scopeDomainZoneOrder($query)
{
return $query
->select('zones.*')
->join('domains',['domains.id'=>'zones.domain_id'])
->orderBy('domains.name')
->orderBy('zone_id');
}
/* RELATIONS */
public function addresses()
{
return $this->hasMany(Address::class)
->active()
->FTNorder()
->with(['system.sessions','system.setup','zone.domain']);
}
public function domain()
{
return $this->belongsTo(Domain::class);
}
public function system()
{
return $this->belongsTo(System::class);
}
/**
* Get the default route for this zone
*/
public function systems()
{
return $this->belongsToMany(System::class)
->withPivot(['default']);
}
}