Skip to content

Commit

Permalink
Merge pull request #5422 from Laravel-Backpack/add-workaround-for-qui…
Browse files Browse the repository at this point in the history
…ck-button-inconsistency

Add workaround for quick button inconsistency
  • Loading branch information
pxpm authored Jan 19, 2024
2 parents f5ee627 + d4f3768 commit 5044460
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/app/Http/Controllers/Operations/Concerns/HasForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function formView(?int $id = null): \Illuminate\Contracts\View\View
{
if ($id) {
// Get entry ID from Request (makes sure its the last ID for nested resources)
$this->data['id'] = $this->crud->getCurrentEntryId() ?? $id;
$this->data['id'] = $this->crud->getCurrentEntryId() ?: $id;
$this->data['entry'] = $this->crud->getEntryWithLocale($this->data['id']);
}

Expand Down Expand Up @@ -105,7 +105,7 @@ public function formAction(?int $id = null, callable $formLogic)
{
if ($id) {
// Get entry ID from Request (makes sure its the last ID for nested resources)
$id = $this->crud->getCurrentEntryId() ?? $id;
$id = $this->crud->getCurrentEntryId() ?: $id;
$entry = $this->crud->getEntryWithLocale($id);
}

Expand Down
7 changes: 6 additions & 1 deletion src/resources/views/crud/buttons/quick.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@php
$access = $button->meta['access'] ?? Str::of($button->name)->studly();
$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();
Expand Down

0 comments on commit 5044460

Please sign in to comment.