Change Address::parent(),Address::children(), improved CI testing
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
use App\Models\{Setup,Zone};
|
||||
use App\Models\{Address,Domain,Setup,Zone};
|
||||
|
||||
/**
|
||||
* Calculate CCITT-CRC16 checksum
|
||||
@@ -85,18 +85,38 @@ if (! function_exists('hexstr')) {
|
||||
* Return our addresses.
|
||||
* If zone provided, limit the list to those within the zone
|
||||
*
|
||||
* @param Zone|NULL $zo
|
||||
* @param Domain|NULL $do
|
||||
* @return Collection
|
||||
*/
|
||||
function our_address(Zone $zo=NULL): Collection
|
||||
function our_address(Domain $do=NULL): Collection
|
||||
{
|
||||
$our = Setup::findOrFail(config('app.id'))->system->addresses;
|
||||
|
||||
return $zo
|
||||
? $our->filter(function($item) use ($zo) { return $item->zone_id === $zo->id; })
|
||||
return $do
|
||||
? $our->filter(function($item) use ($do) { return $item->zone->domain_id === $do->id; })
|
||||
: $our;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of nodes that collect mail directly from us
|
||||
*
|
||||
* @param Domain|NULL $do
|
||||
* @return Collection
|
||||
*/
|
||||
function our_nodes(Domain $do=NULL): Collection
|
||||
{
|
||||
return Address::select(['addresses.id','addresses.zone_id','region_id','host_id','node_id','point_id','addresses.system_id','role'])
|
||||
->join('system_zone',['system_zone.system_id'=>'addresses.system_id','system_zone.zone_id'=>'addresses.zone_id'])
|
||||
->when(! is_null($do),function($query) use ($do) {
|
||||
return $query
|
||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||
->where('domain_id',$do->id);
|
||||
})
|
||||
->active()
|
||||
->FTNorder()
|
||||
->get();
|
||||
}
|
||||
|
||||
if (! function_exists('timew')) {
|
||||
/**
|
||||
* Convert a time into an 32 bit value. This is primarily used to create 8 character hex filenames that
|
||||
|
Reference in New Issue
Block a user