plank/laravel-metable
A package for attaching arbitrary data to Eloquent models
6.3.1
877K downloads/mo
#4234 most downloaded on Packagist
plank/laravel-metable
What this package is like to depend on
Last release 4 months ago
17 Apr 2026
Release timing varies
gaps range from 2 weeks to 1.2 years
Some releases are documented
notes for 18 of 32 stable releases
Nothing withdrawn
no release was ever pulled
10 years old
32 releases · first in 2017
2 releases in the last 12 months
see the full history below
Release timeline
32 releases · Jan 2017 to Apr 2026Releases
latest 32-
6.3.117 Apr 2026Release notes
Open source →What's Changed
- Fix PHP 8.4 explicit nullable type deprecation by @saulens22 in #112
Full Changelog: 6.3.0...6.3.1
-
6.3.005 Apr 2026Release notes
Open source →What's Changed
- Added support for Laravel 13 by @frasmage in #127
- Return Model instance to support chaining by @skauk in #117
New Contributors
Full Changelog: 6.2.0...6.3.0
-
6.2.020 Feb 2025Release notes
Open source →What's Changed
- Laravel 12.x Compatibility by @laravel-shift in #113
New Contributors
- @laravel-shift made their first contribution in #113
Full Changelog: 6.1.0...6.2.0
-
6.1.005 Dec 2024 -
6.0.416 May 2024Release notes
Open source → -
6.0.329 Apr 2024Release notes
Open source → -
6.0.229 Apr 2024 -
6.0.129 Apr 2024 -
6.0.029 Apr 2024Release notes
Open source →Version 6 contains a number of changes to improve the usability, performance and security of the package. Refer to the UPGRADING.md file for detailed instructions on how to upgrade from version 5.
Compatibility
- Added support for PHP 8.3
- Droppped support for PHP 8.0 and below
- Added support for Laravel 10 and 11
- Dropped support Laravel versions 9 and below
- New schema migration adding new columns and improving indexing for searching by meta values. See UPGRADING.md for details
Data Types
- Added
SignedSerializeHandleras a catch-all datatype, which will attempt to serialize the data using PHP'sserialize()function. The payload is cryptographically signed with an HMAC before being stored in the database to prevent PHP object injection attacks. - Deprecated
SerializableHandlerin favor of the newSignedSerializeHandlerdatatype. TheSerializableHandlerwill be removed in a future release. In the interim, added themetable.options.serializable.allowedClassesconfig to protect against unserializing untrusted data. - Deprecated
ArrayHandlerandObjectHandler, due to the ambiguity of nested array/objects switching type. These will be removed in a future release. TheSignedSerializeHandlershould be used instead. - Added
PureEnumHandlerandBackedEnumHandlerwhich adds support for storing enum values as Meta. - Added
StringableHandlerwhich adds support for storingIlluminate\Support\Stringableobjects as Meta. - Added
DateTimeImmutableHandlerwhich adds support for storingDateTimeImmutable/CarbonImmutableobjects as Meta. - The
ModelHandlerwill now validate that the encoded class is a valid Eloquent Model before attempting to instantiate it during unserialization. If the class is invalid, the meta value will returnnull. - The
ModelHandlerwill no longer throw a model not found exception if the model no longer exists. Instead, the meta value will returnnull. This is more in line with the existing behavior of theModelCollectionHandler. - The
ModelCollectionHandlerwill now validate that the encoded collection class is a valid Eloquent collection before attempting to instantiate it during unserialization. If the class is invalid, an instance ofIlluminate\Database\Eloquent\Collectionwill be used instead. - The
ModelCollectionHandlerwill now validate that the encoded class of each entry is a valid Eloquent Model before attempting to instantiate it during unserialization. If the class is invalid, that entry in the collection will be omitted. - Added
getNumericValue(): null|int|floatmethod toHandlerInterfacewhich should convert the original value into a numeric format for indexing, if relevant for the data type. - Added
useHmacVerification(): boolmethod toHandlerInterfacewhich should indicate whether the integrity of the serialized data should be verified with an HMAC.
New Commands
- Added
metable:refreshartisan command which will decode and re-encode all meta values in the database. This is useful if you have changed the data type handlers and need to update the serialized data and indexes in the database.
Efficient Value Search
- The Metable
whereMeta(),whereMetaIn(), andorderByMeta()query scopes can now leverage a prefix index on themeta.valuecolumn. This greatly improves performance when searching for meta values against larger datasets when using applicable operators, e.g.=,%,>,>=,<,<=,<>,LIKE(no leading wildcard). This index is only supported by the'mysql','mariadb','pgsql', and'sqlite'drivers. - The
whereMetaNumeric()andorderByMetaNumeric()query scopes will now scan the indexednumeric_valuecolumn instead of the serializedvaluecolumn. This greatly improves performance when searching for meta values against larger datasets. whereMetaNumeric()query scope will now accept a value of any type. It will be converted to an integer or float by the handler. This is more consistent with the behaviour of the other query scopes.- Added additional query scopes to more easily search meta values based on different criteria:
whereMetaInNumeric()whereMetaNotIn()whereMetaNotInNumeric()whereMetaBetween()whereMetaBetweenNumeric()whereMetaNotBetween()whereMetaNotBetweenNumeric()whereMetaIsNull()whereMetaIsModel()
- If the data type handlers cannot convert the search value provided to a
whereMeta*Numeric()query scope to a numeric value, then an exception will be thrown.
Metable Casting
- Added support for casting meta values to specific types by defining the
$castMetaproperty orcastMeta(): arraymethod on the model. This is similar to thecastsproperty of Eloquent Models used for attributes. All cast types supported by Eloquent Models are also available for Meta values.Values will be cast before values are stored in the database to ensure that they are indexed consistently - Added
mergeMetaCasts()method which can be used to override the defined cast on a meta key at runtime.
Encrypt Meta
- Added the
setMetaEncrypted()method which will encrypt data before storing it in the database and decrypt it when retrieving it. This is useful for storing sensitive data in the meta table. - Prefixing a meta cast with
encrypted:will automatically encrypt all values for that meta key.
Metable Attributes
- Added optional trait
MetableAttributeswhich can further extend theMetabletrait allowing access to meta values as model attributes using ameta_prefix. This can be useful for type hinting, IDE autocompletion, static analysis, and usage in Blade templates.
Meta
- Added
$meta->numeric_valueattributes, which are used for optimizing queries filtering by meta value - Added
$meta->hmacattribute, which is used by some data type handlers to validate that the payload has not been tampered with. - Added
$meta->raw_valuevirtual attribute, which exposes the raw serialized value of the meta key. This is useful for debugging purposes. - Added
encrypt()method, used internally by theMetable::setMetaEncrypted()method
Full Changelog: 5.4.0...6.0.0
-
5.4.016 Feb 2023 -
5.3.118 Nov 2022Nothing published for this version
-
5.3.022 Oct 2022Nothing published for this version
-
5.2.119 Aug 2022Nothing published for this version
-
5.2.009 Feb 2022Nothing published for this version
-
5.1.126 Dec 2021Nothing published for this version
-
5.1.025 Oct 2021Nothing published for this version
-
5.0.203 Oct 2021Nothing published for this version
-
5.0.124 Sep 2021 -
5.0.011 Feb 2021Release notes
Open source →- New schema migration: improved database indexing. See UPGRADING.md for details.
- Added config
meta.applyMigrations. When set to false, migration paths will not be loaded from the package. Use this if you wish to override the default schema migrations provided with the package. - Added
setManyMeta()to bulk insert/update multiple keys to a model. Requires Laravel 8.0+ for optimal performance. - Added
removeManyMeta()to bulk delete multiple keys from a model. - Fixed
removeMeta()method causing an error if called with a non-existent key. - Fixed a minor bug with
setMeta()creating duplicates in the cached meta relation when updating a key.
-
4.1.001 Nov 2020Nothing published for this version
-
4.0.015 Oct 2020Release notes
Open source →- fixed support for Laravel 8.0 migration squashing
- Migration files are now loaded from the package itself instead of being published to the local /database/migrations directory. This may cause conflicts when upgrading, see UPGRADING.md for mitigation steps.
-
3.0.013 Sep 2020Release notes
Open source →- Added support for Laravel 8.0 (Thanks @saulens!)
- Moved minimum requirements to PHP 7.3 and Laravel 6.0+
-
2.1.116 Jun 2020 -
2.1.007 Mar 2020 -
2.0.105 Mar 2020Release notes
Open source →- The
joinMetaTable()function now usesgetMorphClass()forMetabletrait to assist with single table inheritance (Thanks @mbryne!)
- The
-
2.0.013 Sep 2019Release notes
Open source →- Moved minimum requirements to PHP 7.2 and Laravel 5.6+
- Added a number of missing return types.
1.1.0 - 2018-05-15
- Added
whereDoesntHaveMeta()query scope (Thanks @tormjens!)
1.0.4 - 2017-08-20
- Added Laravel 5.5 package autodiscovery
- Meta keys are now correctly case sensitive throughout the package (Thanks @Luukvdo!)
- Fixed some PHPDoc typehints (Thanks @Luukvdo!)
1.0.3 - 2017-03-21
- Fixed some compatibility bugs with MySQL
1.0.2 - 2017-02-03
- Removed illegal default from value column in migration
1.0.1 - 2017-01-30
- Added Laravel 5.4 Compatibility
1.0.0 - 2017-01-16
- Initial Release
-
1.1.015 May 2018Nothing published for this version
-
1.0.420 Aug 2017Nothing published for this version
-
1.0.321 Mar 2017Nothing published for this version
-
1.0.203 Feb 2017Nothing published for this version
-
1.0.130 Jan 2017Nothing published for this version
-
1.0.016 Jan 2017Nothing published for this version