This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 211
[Bug] Ardent object not serializable #16
Comments
👍 |
Unfortunately, anonymous functions cannot be serialized in PHP. There are some (convoluted) workarounds. As for serializing model objects I can think up a work-around: instead of de/serializing the original ardent class, derive a second object (i.e. "MyArdentModelSlice") which represents a subset of the base model class (attributes, rules, custom error messages etc.) I'm keen to hear your thoughts on this issue. |
My main point is that Eloquent models are serializable. So Ardent models should also be serializable otherwise basic laravel things like this won't work imho. $users = Cache::remember('users', $minutes, function()
{
return User::all();
}); |
@bryantebeek - Thanks for the elegant solution to the real problem! 👍 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I noticed that when trying to serialize an Ardent model I get an error:
Serialization of 'Closure' is not allowed
Basically the cause is the purgeFilters property is being set to a Closure in the constructor.
Would be great if it can be fixed ;)
Cheers,
Bryan te Beek
The text was updated successfully, but these errors were encountered: