do = $do->withoutRelations(); $this->ao = $ao?->withoutRelations(); $this->since = $since; } /** * Execute the job. */ public function handle(): void { $since = ($this->since ?: Carbon::parse('last monday'))->startOfDay(); $result = Address::FTN() ->ActiveFTN() ->addSelect('addresses.created_at') ->join('systems',['systems.id'=>'addresses.system_id']) ->join('system_zone',['system_zone.system_id'=>'systems.id','system_zone.zone_id'=>'zones.id']) ->whereIn('zones.id',$this->do->zones->pluck('id')) ->where('systems.active',TRUE) ->where('addresses.created_at','>=',$since) ->orderBy('addresses.created_at') ->get(); if ($result->count()) { Log::notice(sprintf('%s:- Sending new nodes since [%s] (%d)',self::LOGKEY,$since,$result->count())); if ($this->ao) Notification::route('netmail',$this->ao->withoutRelations()) ->notify(new NodesNewNetmail($since,$result)); else Notification::route('echomail',$this->do->nodestatus_echoarea) ->notify(new NodesNewEchomail($since,$result)); } else Log::notice(sprintf('%s:- No nodes since [%s]',self::LOGKEY,$since)); } }