buildInHand()) { return null; } $waiting = ZipDownload::query() ->where('status', ZipDownload::STATUS_PENDING) ->whereNull('started_at') ->where('created_at', '<', now()->subMinutes(self::GRACE_MINUTES)) ->min('created_at'); return $waiting === null ? null : Carbon::parse($waiting); } private function buildInHand(): bool { return ZipDownload::query() ->where('status', ZipDownload::STATUS_PENDING) ->whereNotNull('started_at') ->where('started_at', '>', now()->subMinutes(self::IN_HAND_MINUTES)) ->exists(); } }