Skip to content

Commit

Permalink
Merge pull request #2 from HassanZahirnia/patch-1
Browse files Browse the repository at this point in the history
refactor: add type hint for inertia macro
  • Loading branch information
nikuscs committed Aug 12, 2022
2 parents 0d227fa + 6b2a92f commit 0d84741
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/InertiaFlashServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ public function registeringPackage()
Inertia::macro('forget', fn($keys) => Arr::forget($this->sharedProps,$keys));

// Tweak the RedirectResponse to add the Inertia Flash
RedirectResponse::macro('inertia',function($key,$value, bool $append = false){
RedirectResponse::macro('inertia', function($key, $value, bool $append = false): RedirectResponse {
$key = is_array($key) ? $key : [$key => $value];
foreach ($key as $k => $v) {
inertia_flash()->share($k,$v,$append);
}
/** @var RedirectResponse $this */
return $this;
});
}
Expand Down

0 comments on commit 0d84741

Please sign in to comment.