Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/redirect-after' into redirect-…
Browse files Browse the repository at this point in the history
…after

# Conflicts:
#	src/Laravel/src/Fields/Relationships/ModelRelationField.php
  • Loading branch information
lee-to committed Dec 22, 2024
2 parents 1fc0205 + 8e41f6f commit f917d60
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Laravel/src/Fields/Relationships/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function getRedirectAfter(Model|int|null|string $parentId): ?string
return (string) value($this->redirectAfter, $parentId, $this);
}

if($this->isAsync()) {
if ($this->isAsync()) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Fields/Relationships/HasOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function getRedirectAfter(Model|int|null|string $parentId): ?string
return (string) value($this->redirectAfter, $parentId, $this);
}

if($this->isAsync()) {
if ($this->isAsync()) {
return null;
}

Expand Down
7 changes: 3 additions & 4 deletions src/Laravel/src/Http/Controllers/CrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests;
use MoonShine\Contracts\Core\CrudResourceContract;
use MoonShine\Laravel\Contracts\Notifications\MoonShineNotificationContract;
use MoonShine\Laravel\Http\Requests\MoonShineFormRequest;
use MoonShine\Laravel\Http\Requests\Resources\DeleteFormRequest;
Expand Down Expand Up @@ -151,10 +150,10 @@ protected function updateOrCreate(
$resource = $request->getResource();
$item = $resource->getItemOrInstance();

$redirectRoute = static function (CrudResource $resource) use($request): ?string {
$redirectRoute = static function (CrudResource $resource) use ($request): ?string {
$redirect = $request->input('_redirect', $resource->getRedirectAfterSave());

if(\is_null($redirect) && !$resource->isCreateInModal() && $resource->isRecentlyCreated()) {
if (\is_null($redirect) && ! $resource->isCreateInModal() && $resource->isRecentlyCreated()) {
return $resource->getFormPageUrl($resource->getCastedData());
}

Expand Down Expand Up @@ -182,7 +181,7 @@ protected function updateOrCreate(
ToastType::SUCCESS
);

if(\is_null($redirectRoute($resource))) {
if (\is_null($redirectRoute($resource))) {
return back();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Http/Controllers/MoonShineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function reportAndResponse(bool $isAjax, Throwable $e, ?string $redire

$this->toast(__($message), $type);

if(\is_null($redirectRoute)) {
if (\is_null($redirectRoute)) {
return back()->withInput();
}

Expand Down
4 changes: 2 additions & 2 deletions src/Laravel/src/Traits/Resource/ResourceCrudRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ public function getAsyncMethodUrl(

public function getRedirectAfterSave(): ?string
{
if(\is_null($this->redirectAfterSave) && !$this->isAsync()) {
if (\is_null($this->redirectAfterSave) && ! $this->isAsync()) {
$this->redirectAfterSave = PageType::FORM;
}

if(\is_null($this->redirectAfterSave)) {
if (\is_null($this->redirectAfterSave)) {
return null;
}

Expand Down

0 comments on commit f917d60

Please sign in to comment.