Skip to content

Commit

Permalink
add custom payload to action emit
Browse files Browse the repository at this point in the history
  • Loading branch information
luanfreitasdev committed Nov 8, 2021
1 parent 87f9f36 commit d04fd4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion resources/views/components/actions-header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
@php
$parameters = [];
foreach ($action->param as $param => $value) {
$parameters[$param] = $row->{$value};
if (!empty($row->{$value})) {
$parameters[$param] = $row->{$value};
} else {
$parameters[$param] = $value;
}
}
@endphp

@if($action->event !== '')
<a wire:click='$emit("{{ $action->event }}", @json($parameters))'
target="{{ $action->target }}"
Expand Down
6 changes: 5 additions & 1 deletion resources/views/components/actions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
@php
$parameters = [];
foreach ($action->param as $param => $value) {
$parameters[$param] = $row->{$value};
if (!empty($row->{$value})) {
$parameters[$param] = $row->{$value};
} else {
$parameters[$param] = $value;
}
}
@endphp

Expand Down

0 comments on commit d04fd4e

Please sign in to comment.