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
Parameters
Data Type
metadata
array, Collection
Return Type ⇒ \Waad\Metadata\Models\Metadata , null
🔥 addKeysMetadata
This method adds new metadata if it does not exist or adds new values with keys if metadata exists.