How are your casting? What does your $casts array look like?
Can you show your code?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm getting this error when i do a query on the User model, the column notification emails is cast to array, so i don't really know what that means, any idea?
Call to undefined cast [Array] on column [notification_emails] in model [App\Models\User].
The error message is from Illuminate\Database\Eloquent\InvalidCastException
And this exception is only thrown from the Illuminate\Database\Eloquent\Concerns\HasAttributes trait used by the base Eloquent Model class
When it is checking for a cast it couldn't find.
You either have the cast set with a capital A somewhere (check also for ->withCasts(...) usage in a query result), or have a cache problem (remove any .php files from your ./bootstrap/cache folder and then run composer dump-autoload).
Hope some of it helps.
Please or to participate in this conversation.