πCreate Metadata
Creating and adding metadata has one morph relationship (one object)
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
$company->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
]);
// return Metadata Model or null metadata
array, Collection
π₯ addKeysMetadata
addKeysMetadataThis method adds new metadata if it does not exist or adds new values with keys if metadata exists.
Example Usage addKeysMetadata
addKeysMetadata keys
array, Collection, string, int, null
value
array, Collection, string, int, float, bool, null
π₯ addKeyMetadata
addKeyMetadata It's Alias of the `addKeysMetadata` method used for adding Individual Key
Example Usage addKeyMetadata
addKeyMetadata key
string, int, null
value
array, Collection, string, int, float, bool, null
Last updated