isMethod('post')) return []; return [ 'src' => [ 'required', 'exists:addresses,id', ], 'dst' => [ 'required', 'exists:addresses,id', 'different:src', function ($attribute,$value,$fail) use ($request) { $dst = Address::withTrashed()->findOrFail($value); $src = Address::withTrashed()->findOrFail($request->src); if ((! $dst->active) && ($dst->system_id !== $src->system_id) && ($src->system->name !== System::default)) $fail('Destination must be active, or be from the system system'); }, function ($attribute,$value,$fail) use ($request) { $dst = Address::withTrashed()->findOrFail($value); $src = Address::withTrashed()->findOrFail($request->src); 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'); }, ], ]; } }