-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Fix nested flexible #250
base: master
Are you sure you want to change the base?
Fix nested flexible #250
Conversation
It allows to get the right model when there is nested flexible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does $this->model
contain in your case ? Is it a resource ?
Hello Toon, this is the model that needs to be associated with the media using spatie laravel media library. |
I see what you're doing here. I also have some trouble getting the right model back in case of nested layouts supporting media. In my case I can fix it with a custom accessor method: public function getSlidingCardsAttribute()
{
return $this->flexible('sliding_cards', [
'sticky_story_sliding_card' => StickyStorySlidingCard::class,
])->tap(fn(Collection $cards) => $cards->each->setModel($this->model));
} What's happening here is that The (I do wonder whether |
Hmm, sorry, this will fail in CMS context because This implementation works inside and outside of Nova: $out = $this->flexible('sliding_cards', [
'sticky_story_sliding_card' => StickyStorySlidingCard::class,
]);
if ($out instanceof Collection) {
$out->each->setModel($this->model);
}
return $out; |
Please use this pr #267 |
It allows to get the right model when there is nested flexible.