Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Nov 21, 2024
1 parent 5d5f5dc commit 3e46420
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 45 deletions.
78 changes: 39 additions & 39 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ window.$http = Axios.create({
// Cookie
window.$cookie = new Cookie('__root_');

// Handle the relation frame load event
document.addEventListener('relation-frame-loaded', (event) => {
if (window.location.href !== event.detail.url) {
window.history.replaceState(window.history.state, document.title, event.detail.url);
Expand Down
14 changes: 8 additions & 6 deletions src/Fields/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,10 @@ public function paginate(Request $request, Model $model): LengthAwarePaginator
->withCount($this->withCount)
->latest()
->paginate(
$request->input($this->getPerPageKey(), $request->isTurboFrameRequest()
? 5
: $relation->getRelated()->getPerPage())
$request->input(
$this->getPerPageKey(),
$request->isTurboFrameRequest() ? 5 : $relation->getRelated()->getPerPage()
)
)->withQueryString();
}

Expand Down Expand Up @@ -875,9 +876,10 @@ public function routes(Router $router): void
public function registerRouteConstraints(Request $request, Router $router): void
{
$router->bind($this->getRouteKeyName(), function (string $id, Route $route) use ($router): Model {
return $id === 'create'
? $this->getRelation($route->parentOfParameter($this->getRouteKeyName()))->make()
: $this->resolveRouteBinding($router->getCurrentRequest(), $id);
return match ($id) {
'create' => $this->getRelation($route->parentOfParameter($this->getRouteKeyName()))->make(),
default => $this->resolveRouteBinding($router->getCurrentRequest(), $id),
};
});
}

Expand Down

0 comments on commit 3e46420

Please sign in to comment.