nova-flexible-content
nova-flexible-content copied to clipboard
Casts method inside HasFlexible trait
Inside the HasFlexible trait (which we're using in FlexibleCast) we're returning the raw value (string) when in the following context :
if(app()->getProvider(NovaServiceProvider::class) && !app()->runningInConsole() && !app()->environment('testing')) {
return $value;
}
In other words, if you're testing inside Nova itself it won't return the casted value (because the field will take care of it by itself). Is that your case ?
Originally posted by @toonvandenbos in https://github.com/whitecube/nova-flexible-content/issues/311#issuecomment-981578218
Could you explain this case - for what we need returns $value string if we want to use CASTS features?
Maybe you meant the opposite?
if(!app()->getProvider(NovaServiceProvider::class) && app()->runningInConsole() && app()->environment('testing')) {
When I apply this code in MyFlexibleCast class and implements it for custom class, I faced with issue with laravel-nova pages, we faced the problem "Undefined property: stdClass::$layout". After a few minutes research I noticed that this happened in Whitecube\NovaFlexibleContent\Value\Resolver class extractValueFromResource method. This happened because we do data_get method from our resource and it's returns to us casts data, but we should recievied non-casts data from table.
// $value = data_get($resource, str_replace('->', '.', $attribute)) ?? [];
$value = $resource->getRawOriginal(str_replace('->', '.', $attribute)) ?? [];
And we can just call the getRawOriginal method (laravel 7+). And everything will be works!
Man... trying all this stuff now - I'm so confused so just changed this in whitecube and hoepfully it'll stop returning a string..
Lol nope - https://share.getcloudapp.com/d5unwGr9 - I know this is... something as I'm close and it works in routes.. just not in... like anywhere else - just returning a string.
Ahhh! That's all I want - https://share.getcloudapp.com/wbuQ9RyW - I'm going crazy here lol - got phpStorm open trying to do this
Ahhh! That's all I want - https://share.getcloudapp.com/wbuQ9RyW - I'm going crazy here lol - got phpStorm open trying to do this
Sorry for the delay, did you solve your problem?
Hey!! Nah it's all good and great timing - I actually just figured out today how to like... create a templating system using your flexible field thingie (populate rows on drop down of my other Vue element)... so yeh - it works awesomely! Please don't leave again! Haha... I guess I need to like show my support and sponsor you guys otherwise I can't really complain if you guys go AWOL for months lol