{{-- Permission Button Component Usage: Props: permission : string - permission key e.g. 'shifts.create' href : string - if set, renders an tag onclick : string - if set (and no href), renders a type : string - button type (default: button) class : string - CSS classes for the enabled state icon : string - lucide icon name label : string - visible text iconOnly : bool - show icon only (default false) method : string - for form-based actions: 'POST','DELETE','PATCH' (wraps in form) formAction : string - URL for form-based actions confirmMsg : string - JS confirm message before action --}} @props([ 'permission', 'href' => null, 'onclick' => null, 'type' => 'button', 'class' => '', 'icon' => null, 'label' => '', 'iconOnly' => false, 'method' => null, 'formAction' => null, 'confirmMsg' => null, ]) @php $hasPermission = auth()->user()->hasPermission($permission); $disabledClass = 'opacity-50 cursor-not-allowed pointer-events-none'; $tooltip = $hasPermission ? '' : 'لا تملك صلاحية للقيام بهذا الإجراء'; @endphp @if($method && $formAction) {{-- Form-based action (DELETE, PATCH, POST) --}} @csrf @method($method) @if($icon)@endif @if(!$iconOnly){{ $label }}@endif @elseif($href) {{-- Link button --}} @if($hasPermission) @if($icon)@endif @if(!$iconOnly){{ $label }}@endif @else @if($icon)@endif @if(!$iconOnly){{ $label }}@endif @endif @else {{-- Regular button --}} @if($icon)@endif @if(!$iconOnly){{ $label }}@endif @endif