{{-- Premium-feature badge. Renders a shiny gold crown next to feature
labels when the current workspace's plan does NOT include the
feature. Clicking jumps to /pricing.
Usage:
Props:
feature string|array — single flag key OR array of keys
any bool — when an array is passed: true = require ANY
of the flags, false = require ALL. Default false.
size string — sm | md | lg (default md)
label string|null — optional tooltip override
link bool — true (default) renders a clickable to
/account/plans. Pass false when the crown is
already INSIDE another (e.g. the /more
feature cards): a link-in-link is invalid HTML
and the browser hoists the inner one out, so we
render a plain badge instead — the parent
card already routes to the feature's paywall.
--}}
@props([
'feature' => null,
'any' => false,
'size' => 'md',
'label' => null,
'link' => true,
])
@php
if ($feature === null || $feature === '') {
return;
}
$workspace = auth()->user()?->currentWorkspace ?? null;
$flags = is_array($feature) ? $feature : [$feature];
// Platform admins always see content — they're not "missing" anything.
$isAdmin = false;
try {
$u = auth()->user();
if (
$u &&
((method_exists($u, 'hasRole') && ($u->hasRole('Super Admin') || $u->hasRole('Admin'))) ||
in_array((string) ($u->role ?? ''), ['admin', 'A', 'super-admin', 'platform-admin'], true))
) {
$isAdmin = true;
}
} catch (\Throwable $e) {
}
if ($isAdmin) {
return;
}
$checker = fn($key) => \App\Services\PlanLimitGuard::hasFeature($workspace, $key);
$satisfied = $any ? collect($flags)->contains($checker) : collect($flags)->every($checker);
if ($satisfied) {
return;
}
$dim = match ($size) {
'sm' => 'w-3 h-3',
'lg' => 'w-4.5 h-4.5',
default => 'w-3.5 h-3.5',
};
$tooltip = $label ?: __('Premium feature — upgrade your plan to unlock');
$tag = $link ? 'a' : 'span';
@endphp
<{{ $tag }} @if ($link) href="{{ url('/account/plans') }}" @endif
title="{{ $tooltip }}" class="plan-crown inline-flex items-center justify-center align-middle ml-1 leading-none"
aria-label="{{ $tooltip }}">
{{ $tag }}>
@once
@push('styles')
@endpush
@endonce