clrghouz/app/Models/Zone.php

40 lines
607 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Traits\ScopeActive;
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');
}
/* RELATIONS */
public function addresses()
{
return $this->hasMany(Address::class);
}
public function domain()
{
return $this->belongsTo(Domain::class);
}
public function system()
{
return $this->belongsTo(System::class);
}
}