nova-flexible-content
nova-flexible-content copied to clipboard
Any idea why it doesn't get cast in Laravel Nova action (but does in the route)
So I have a code that cycles through some products
foreach($opps as $opp) {
ray($opp);
$items = array();
ray($opp->products);
foreach($opp->products as $product) {
$items[] = ['rate' => $product->price, 'productname' => $product->product_name, 'productfeature' => $product->product_benefit];
}
Everything works beautifully and as you can see I use Ray and it comes out with Eloquent for the products stuff which is Whitecube - it loops through everything is beautiful output:
https://share.getcloudapp.com/RBuZ4GnO
As you can see it gets cast to the Whitecube collection but.... when I do the same thing except in an action I get following: https://share.getcloudapp.com/WnuDBOy6
So for some reason it doesn't get cast - here's the code starting in my action: https://share.getcloudapp.com/geuy4LmN
So.. I'm investigating the cause now but if you have any input on why it fails to cast (and is needing me to rewrite the code) it would be much appreciated. Thanks!
Video time! - https://share.getcloudapp.com/WnuDBo8K
As you seem to have found out, this is a duplicate of https://github.com/whitecube/nova-flexible-content/issues/311 and https://github.com/whitecube/nova-flexible-content/issues/389
It looks like we have not accounted for every use case when we wrote the code that decides when to cast and not to cast. We would gladly accept a PR with a fix for this.