Skip to content

Commit

Permalink
fix: minor
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Sep 18, 2024
1 parent 1c33aec commit e36ee10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/Laravel/src/Traits/Resource/ResourceQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public function isItemExists(): bool
*/
public function getItem(): mixed
{
if (!is_null($this->item)) {
return $this->item;
}

if (is_null($this->getItemID())) {
return null;
}
Expand All @@ -114,6 +118,10 @@ public function getItem(): mixed
*/
public function getItemOrInstance(): mixed
{
if (!is_null($this->item)) {
return $this->item;
}

if (is_null($this->getItemID())) {
return $this->getDataInstance();
}
Expand All @@ -128,6 +136,10 @@ public function getItemOrInstance(): mixed
*/
public function getItemOrFail(): mixed
{
if (!is_null($this->item)) {
return $this->item;
}

return $this->itemOr(
fn () => $this->findItem(orFail: true)
);
Expand Down
5 changes: 4 additions & 1 deletion tests/Feature/Controllers/CrudControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ function storeResource(ModelResource $resource, $saveData)
$resource->getRoute('crud.store'),
$saveData
)
->assertRedirect();
->assertRedirect()
->assertRedirectContains(
str_replace('5', '', $resource->getFormPageUrl(5))
);

return Item::query()->where('name', 'Test name storeData')->first();
}

0 comments on commit e36ee10

Please sign in to comment.