resolveOrderModel('Order'); if (! $class) { return null; } return $this->hasMany($class); } /** * Check if user can claim a vanity URL. * * Requires either: * - A paid subscription (Creator/Agency package) * - A one-time vanity URL boost purchase */ public function canClaimVanityUrl(): bool { // Check for vanity URL boost $hasBoost = $this->boosts() ->where('feature_code', 'bio.vanity_url') ->where('status', Boost::STATUS_ACTIVE) ->exists(); if ($hasBoost) { return true; } // Check for paid subscription (Creator or Agency package) $orders = $this->orders(); if (! $orders) { return false; } $hasPaidSubscription = $orders ->where('status', 'paid') ->where('total', '>', 0) ->whereHas('items', function ($query) { $query->whereIn('item_code', ['creator', 'agency']); }) ->exists(); return $hasPaidSubscription; } /** * Resolve an Order model class, checking common namespaces. */ protected function resolveOrderModel(string $model): ?string { $candidates = [ "Core\\Mod\\Commerce\\Models\\{$model}", "Core\\Mod\\Social\\Models\\{$model}", "App\\Models\\{$model}", ]; foreach ($candidates as $candidate) { if (class_exists($candidate)) { return $candidate; } } return null; } }