@untymage A cast will only do a query if you’re actually doing a query in the cast class (which you shouldn’t). A cast should just convert one value to a different representation.
Jan 29, 2021
6
Level 13
Disable CastAttribute when performing a query ?
I have a column which accepts a CastAttribute , How can i temporary disable casting when i perform a query ? I mean:
$post->comments()->pluck('level');
the raw property in my table have integer value but i casted it to string, How can tell laravel to ingore casting for level property in this query ?
Level 104
If you drop down to a Query Builder, you will get the raw attribute value:
$post->comments()->toBase()->pluck('level');
2 likes
Please or to participate in this conversation.