Skip to content

Commit

Permalink
quick button studly inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
pxpm committed Jan 13, 2024
1 parent f5ee627 commit 916a0a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 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
8 changes: 8 additions & 0 deletions src/app/Library/CrudPanel/Traits/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Backpack\CRUD\app\Exceptions\AccessDeniedException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

trait Access
{
Expand Down Expand Up @@ -38,6 +39,13 @@ public function hasAccess(string $operation, $entry = null): bool
{
$condition = $this->get($operation.'.access');

// this shouldn't happen, but in v6 we introduced the "quick" button with an inconsistency with other buttons.
// the quick button name is converted with `Str::studly()` to get the access string and that makes it impossible
// for this function to determine the proper access key. For example, a quick button with the name `comment`
// would have the access key `Comment`, while create, update, delete etc have the access keys `create`, `update`, `delete` without transformation.
// we should remove the transformation in vendor\backpack\crud\src\resources\views\crud\buttons\quick.blade.php and remove this line from here in v7.
$condition = $condition ?? $this->get(Str::camel($operation).'.access');

if (is_callable($condition)) {
// supply the current entry, if $entry is missing
// this also makes sure the entry is null when missing
Expand Down

0 comments on commit 916a0a3

Please sign in to comment.