@php $access = (function() use ($crud, $button) { if (isset($button->meta['access']) && $button->meta['access'] !== null && $button->meta['access'] !== false) { return $button->meta['access']; } return !is_null($crud->get(Str::of($button->name)->studly().'.access')) ? Str::of($button->name)->studly() : $button->name; })(); $icon = $button->meta['icon'] ?? ''; $label = $button->meta['label'] ?? Str::of($button->name)->headline(); $defaultHref = url($crud->route. ($entry?->getKey() ? '/'.$entry?->getKey().'/' : '/') . Str::of($button->name)->kebab()); $defaultClass = match ($button->stack) { 'line' => 'btn btn-sm btn-link', 'top' => 'btn btn-outline-primary', 'bottom' => 'btn btn-sm btn-secondary', default => 'btn btn-outline-primary', }; $wrapper = $button->meta['wrapper'] ?? []; $wrapper['element'] = $wrapper['element'] ?? 'a'; $wrapper['href'] = $wrapper['href'] ?? $defaultHref; if (is_a($wrapper['href'], \Closure::class, true)) { $wrapper['href'] = ($wrapper['href'])($entry, $crud); } $wrapper['class'] = $wrapper['class'] ?? $defaultClass; @endphp @if ($access === true || $crud->hasAccess($access, isset($entry) ? $entry : null)) <{{ $wrapper['element'] }} @foreach ($wrapper as $attribute => $value) @if (is_string($attribute)) {{ $attribute }}="{{ $value }}" @endif @endforeach > @if ($icon) @endif {{ $label }} @endif