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) ->where('point_id',$o->point_id)
->get(); ->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') return view('system/address-merge')
->with('o',$o) ->with('o',$o)
->with('oo',$oo); ->with('oo',$oo);

View File

@ -42,7 +42,11 @@ class AddressMerge extends FormRequest
$dst = Address::withTrashed()->findOrFail($value); $dst = Address::withTrashed()->findOrFail($value);
$src = Address::withTrashed()->findOrFail($request->src); $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'); $fail('Source and Destination must be the same FTN');
}, },
], ],

View File

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