@props([
'permission' => null,
'route' => null,
'url' => null,
'icon' => null,
'label' => '',
'deniedLabel' => null,
'deniedTitle' => null,
'class' => 'btn btn-primary',
'disabledClass' => 'btn btn-outline-secondary',
'iconClass' => 'feather-14 me-25',
'target' => null,
'wrapper' => 'span',
'iconPosition' => 'left',
])
@php
$allowed = empty($permission) || auth()->check() && auth()->user()->can($permission);
$deniedLabel = $deniedLabel ?? $label;
$href = $url ?? ($route ? route(...(array) $route) : '#');
$targetAttr = $target ? 'target="'.$target.'"' : '';
$iconHtml = $icon ? '' : '';
@endphp
@if($allowed)
merge(['class' => $class]) !!}>
@if($iconPosition === 'left'){!! $iconHtml !!}@endif
{{ $label }}
@if($iconPosition === 'right') {!! $iconHtml !!}@endif
@else
<{{ $wrapper }} data-bs-toggle="tooltip"
data-bs-placement="top"
title="{{ $deniedTitle ?? __('locale.permission.action_not_allowed') }}"
class="d-inline-block permission-denied-wrap">
{{ $wrapper }}>
@endif