Enable merging address in a domain that has flatten set

This commit is contained in:
Deon George 2023-09-11 22:57:29 +10:00
parent ab7f661800
commit e553bb4ce6
3 changed files with 14 additions and 2 deletions

View File

@ -386,6 +386,15 @@ class SystemController extends Controller
->where('point_id',$o->point_id)
->get();
if ($o->zone->domain->flatten)
$oo = $oo->merge(Address::withTrashed()
->whereIn('zone_id',$o->zone->domain->zones->pluck('id'))
->where('host_id',$o->host_id)
->where('node_id',$o->node_id)
->where('point_id',$o->point_id)
->get()
);
return view('system/address-merge')
->with('o',$o)
->with('oo',$oo);

View File

@ -42,7 +42,11 @@ class AddressMerge extends FormRequest
$dst = Address::withTrashed()->findOrFail($value);
$src = Address::withTrashed()->findOrFail($request->src);
if ($src->ftn !== $dst->ftn)
if ($src->zone->domain->flatten && $dst->zone->domain->flatten) {
if ((! $src->zone->domain->zones->pluck('id')->contains($dst->zone_id)) || (! $dst->zone->domain->zones->pluck('id')->contains($src->zone_id)))
$fail('Source must be Destination\'s domain zone');
} elseif ($src->ftn !== $dst->ftn)
$fail('Source and Destination must be the same FTN');
},
],

View File

@ -535,7 +535,6 @@ class Address extends Model
$o = (new self)
->select('addresses.*')
->join('zones',['zones.id'=>'addresses.zone_id'])
//->join('domains',['domains.id'=>'zones.domain_id'])
->when($trashed,function($query) {
$query->trashed();
},function($query) {