πCreate Metadata
Creating and adding metadata
Metadata supports all data types in PHP that can store null, empty, string, int, float and array
π₯ createMetadata
createMetadata// Syntax
$model->createMetadata(array|Collection): \Waad\Metadata\Models\Metadata;To create metadata you can use the createMetadata function, which is capable of handling various data types such as strings, integers, floats, arrays, and null values. Below is an example demonstrating how metadata can be structured and assigned to a company object:
Example Usage
// Usage array input
$model->createMetadata([
'language' => 'English', // string data type
'is_visible' => true, // boolean data type
'phone' => '', // empty string
'slug' => null, // null value
'theme' => 'dark', // string data type
'views' => 100, // integer data type
'rating' => 4.5, // float data type
'sports' => ['football', 'basketball'], // array data type
]);
// Usage Collection input
$model->createMetadata(collect(['language' => 'English', 'theme' => 'dark']));
metadata
array, Collection
π₯ createManyMetadata
Example Usage
metadatas
array, Collection
π₯ addKeysMetadataById
This method adds new values with keys if metadata exists.
Example Usage
id
string
keys
array, Collection, string, int, null
value
array, Collection, string, int, float, bool, null
π₯ addKeyMetadataById
addKeyMetadataById It's an Alias of the `addKeysMetadataById` method used for adding Individual Key
Example Usage
id
string
key
string, int, null
value
array, Collection, string, int, float, bool, null
Last updated