-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
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;
$collection->encode(Optimus::connection('Main'));
$collection->decode(Optimus::connection('Main'));
antonkomarev
Metadata
Metadata
Assignees
Labels
No labels