π«Update Metadata
The laravel-model-metadata package allows you to easily update metadata associated with your models.
π₯ updateMetadata
updateMetadata// Syntax
$model->updateMetadata(array|Collection $metadata): boolExample Usage
$company->createMetadata(['theme' => 'dark']);
$company->updateMetadata(['theme' => 'light']);
// Using array
$company->updateMetadata(['theme' => 'auto', 'year' => 1997]);
// The updated metadata will be:
[
'theme' => 'auto',
'year' => 1997,
];
// Using Collection
$company->updateMetadata(collect(['theme' => 'dark', 'year' => 1998]));
// The updated metadata will be:
[
'theme' => 'dark',
'year' => 1998,
];Parameters
Data Types
metadata
array, Collection
π₯ updateKeysMetadata
updateKeysMetadataExample Usage
Parameters
Data Types
keys
array, Collection, string, int, null
value
array, Collection, string, int, float, bool, null
π₯ updateKeyMetadata
updateKeyMetadata It's Alias of the `updateKeysMetadata` method used for updating Individual Key
Example usage
Parameters
Data Types
key
string, int, null
value
array, Collection, string, int, float, bool, null
Last updated