You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with multiple arrays of encoded/decoded ids and found it helpful to register 2 macros for encoding and decoding the whole collection. Thought I would share to either be implemented or someone can use.
Register within a service provider:
// Optimus decode
Collection::macro('decode', function ($connection) {
return $this->map(function ($value) use ($connection) {
return $connection->decode($value);
});
});
// Optimus encode
Collection::macro('encode', function ($connection) {
return $this->map(function ($value) use ($connection) {
return $connection->encode($value);
});
});
Use by passing a optimus connection and the collection will return an encoded/decoded version;
I'm working with multiple arrays of encoded/decoded ids and found it helpful to register 2 macros for encoding and decoding the whole collection. Thought I would share to either be implemented or someone can use.
Register within a service provider:
Use by passing a optimus connection and the collection will return an encoded/decoded version;
The text was updated successfully, but these errors were encountered: