Skip to content

JS::from helper change breaks converting paginator to json object #56252

Closed
@robtesch

Description

@robtesch

Laravel Version

12.20.0

PHP Version

8.4.10

Database Driver & Version

No response

Description

This issue references this recent change: #56159

Unfortunately this change broke my production quite badly and I had to revert. My use-case is that I regularly provide the front-end Vue components with initial data as props using the JS::from helper within the blade view, example:

@section("content")
  <my-component
    :initial-data="{{ Js::from($intitialData) }}"
  ></my-component>
@endsection

Often the data provided is an Illuminate\Pagination\LengthAwarePaginator which of course is Htmlable.

I understand the motivation behind this PR, but I feel it should at least be opt-in rather than the default behaviour. Alternatively, perhaps it could only be triggered if the output would be {} without this?

Steps To Reproduce

  1. Pass a Illuminate\Pagination\LengthAwarePaginator to a blade view from the controller.
  2. Attempt to pass this as a prop to vue component using Js::from helper as shown above.
  3. Instead of a nicely formed json object being provided as a prop, an html string is provided to the component instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions