Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Prevent error when cascadeContent is an Eloquent Model #10759

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Sep 4, 2024

This pull request fixes an issue when passing an Eloquent Model into a view's `->cascadeContents() method.

I'm currently fixing a bug in Runway, with its frontend routing feature, where the page variable isn't available in Blade views (see statamic-rad-pack/runway#590).

The page variable is only set when the view has cascadeContent set, whereas previously we were only passing an array of the augmented model into the View::with() method.

However, when passing the model to View::cascadeContents(), it resulted in an error because the model doesn't have an id method on it.

I could add an ID method but that has caused issues in the past where folks have already implemented their own id methods.

Ideally, for Eloquent Models, it'd use the model's key anyway.

Anyways, feel free to reject if you don't want this in Core and I'll try and find another way around it.

@jasonvarga jasonvarga merged commit fa9e1eb into 5.x Sep 5, 2024
19 checks passed
@jasonvarga jasonvarga deleted the fix-eloquent-model-responses branch September 5, 2024 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants