πŸ’«Update Metadata

The laravel-model-metadata package allows you to easily update metadata associated with your models.

πŸ”₯ updateMetadata

// Syntax
$model->updateMetadata(array|Collection $metadata): bool

Example 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

Return Type β‡’ Boolean


πŸ”₯ updateKeysMetadata

Example Usage

Parameters
Data Types

keys

array, Collection, string, int, null

value

array, Collection, string, int, float, bool, null

Return Type β‡’ Boolean


πŸ”₯ updateKeyMetadata

Example usage

Parameters
Data Types

key

string, int, null

value

array, Collection, string, int, float, bool, null

Return Type β‡’ Boolean

Last updated