Move DomainController::NODE* to Address::NODE*, make role mandatory in the database, change logic so that mail generated by the host comes from a node address.

This commit is contained in:
Deon George
2022-01-24 22:56:13 +11:00
parent efa7195633
commit d660d5a6df
15 changed files with 143 additions and 110 deletions

View File

@@ -9,17 +9,6 @@ use App\Models\{Address,Domain,Zone};
class DomainController extends Controller
{
public const NODE_ACTIVE = 0; // Active
public const NODE_ZC = 1<<0; // Zone
public const NODE_RC = 1<<1; // Region
public const NODE_NC = 1<<2; // Host
public const NODE_HC = 1<<3; // Hub
public const NODE_POINT = 1<<4; // Point
public const NODE_PVT = 1<<5; // Pvt
public const NODE_HOLD = 1<<6; // Hold
public const NODE_DOWN = 1<<7; // Down
public const NODE_UNKNOWN = 1<<8; // Down
// http://ftsc.org/docs/frl-1002.001
public const NUMBER_MAX = 0x7fff;
@@ -65,7 +54,7 @@ class DomainController extends Controller
*/
public function api_hosts(Zone $o,int $region): Collection
{
$oo = Address::where('role',self::NODE_NC)
$oo = Address::where('role',Address::NODE_NC)
->where('zone_id',$o->id)
->when($region,function($query,$region) { return $query->where('region_id',$region)->where('node_id',0); })
->when((! $region),function($query) use ($region) { return $query->where('region_id',0); })
@@ -107,7 +96,7 @@ class DomainController extends Controller
*/
public function api_regions(Zone $o): Collection
{
$oo = Address::where('role',self::NODE_RC)
$oo = Address::where('role',Address::NODE_RC)
->where('zone_id',$o->id)
->where('node_id',0)
->where('point_id',0)