use App\Notifications\PropertyExpired; public function handle(): int { $now = \Carbon\Carbon::now(); $expiredListings = Property::where('status', 'active') ->whereNotNull('expires_at') ->where('expires_at', '<=', $now) ->get(); if ($expiredListings->isEmpty()) { $this->info('No expired listings found.'); return Command::SUCCESS; } foreach ($expiredListings as $property) { $property->update(['status' => 'expired']); $agent = $property->agent; if ($agent) { $notification = new PropertyExpired($property); // ✅ Send Laravel notification (database, email, etc.) $agent->notify($notification); // ✅ Trigger CallMeBot SMS if applicable $notification->sendCallMeBotSMS($agent); $this->info("Property ID {$property->id} expired and agent notified."); } } $this->info("✅ {$expiredListings->count()} listing(s) expired."); return Command::SUCCESS; }