@inject('helperClass','PowerComponents\LivewirePowerGrid\Helpers\Helpers') @props([ 'actions' => null, 'theme' => null, 'row' => null, ])
@if(isset($actions) && count($actions) && $row !== '') @foreach($actions as $key => $action) @php $class = filled($action->class) ? $action->class : $theme->actions->headerBtnClass; $class = $attributes->class($class); if($action->singleParam) { $actionParameters = $helperClass->makeActionParameter($action->param, $row); } else { $actionParameters = $helperClass->makeActionParameters($action->param, $row); } $rules = $helperClass->makeActionRules($action, $row); $ruleRedirect = data_get($rules, 'redirect'); $ruleDisabled = data_get($rules, 'disable'); $ruleHide = data_get($rules, 'hide', false); $ruleSetAttribute = data_get($rules, 'setAttribute'); $ruleEmit = data_get($rules, 'emit'); $ruleEmitTo = data_get($rules, 'emitTo'); $ruleCaption = data_get($rules, 'caption'); $action->emit = false; $action->emitTo = false; if(isset($ruleSetAttribute['attribute'])) { $class = $attributes->merge([$ruleSetAttribute['attribute'] => $ruleSetAttribute['value']])->class($class); } if (filled($ruleEmit)) { $event['event'] = $ruleEmit['event']; $event['params'] = $helperClass->makeActionParameters(data_get($ruleEmit, 'params', []), $row); $action->emit = true; } else if (filled($ruleEmitTo) ) { $event['to'] = $ruleEmitTo['to'] ?? ''; $event['event'] = $ruleEmitTo['event']; $event['params'] = $helperClass->makeActionParameters(data_get($ruleEmitTo, 'params', []), $row); $action->emitTo = true; } else { if (filled($action->event)) { $action->emit = true; $event['event'] = $action->event; $event['params'] = $actionParameters; if (filled($action->to)) { $action->emitTo = true; $event['to'] = $action->to; } } } @endphp
@if((filled($action->event) || isset($event['event']) || filled($action->view)) && is_null($ruleRedirect)) @endif @if(filled($ruleRedirect)) {!! $ruleCaption ?? $action->caption !!} @endif @if(filled($action->route)) @if(strtolower($action->method) !== 'get')
@method($action->method) @csrf
@else {!! $ruleCaption ?? $action->caption !!} @endif @endif
@endforeach @endif