tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.83k stars 247 forks source link

"Resolving Infinite Loop Issues in resolveBindings Function" #761

Closed M0einRahmani closed 1 month ago

M0einRahmani commented 2 months ago

"I used (new Ziggy())->jsonSerialize() in Exceptions\Handler.php in my Laravel + InertiaJS project. When an error or exception occurs, I noticed that the resolveBindings function gets stuck in an infinite loop." #

Exceptions\Handler.php

    public function register(): void
    {
        $this->reportable(function (Throwable $e) {
            //
        });

        $this->renderable(function (Throwable $e, Request $request) {
            $status = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500;
            return Inertia::render('Error', [
                'ziggy' => fn() => (new Ziggy())->jsonSerialize(),
                //
            ])
                ->toResponse($request)
                ->setStatusCode($status);
        });
    }

Pull request: #760