🧽Forget Metadata

Clear content of metadata make it null, or remove specific keys.

🔥 forgetMetadataById

// Syntax
$model->forgetMetadataById(string $id): bool

Example Usage


// Forget the content of metadata by id
if ($model->forgetMetadataById($id)) {
    echo "Metadata successfully forged";
} else {
    echo "No metadata to forget or forgetting failed";
}


$status = $model->forgetMetadataById($id); // return boolean
// Will be : []

Return Type ⇒ Boolean


🔥 forgetKeysMetadataById

Delete specific values by keys from the metadata field by id.

// Syntax
// @param $id string
// @param $keys array|Collection|string|int|null
$model->forgetKeysMetadataById($id, $keys = null): bool

Example Usage


// create metadata
$model->createMetadata(['theme' => 'dark', 'lang' => 'Arabic', 'year' => 1997]);

// Using array keys
$model->forgetKeysMetadataById($id, ['theme', 'year']);
// Will become: ['lang' => 'Arabic']

// Using Collection keys
$model->forgetKeysMetadataById($id, collect(['theme', 'year']));

// Using individual key
$model->forgetKeysMetadataById($id, 'theme');
$model->forgetKeysMetadataById($id, 3);   // if metadata list array not associative (keys)
Parameters
Data Types

id

string

keys

array, Collection, string, int, null

Return Type ⇒ Boolean


🔥 forgetKeyMetadataById

// Syntax
$model->forgetKeyMetadataById(string $id, string|int|null $key = null): bool

Example usage

$company->forgetKeyMetadataById($id, 'theme');

$company->forgetKeyMetadataById($id, 4);  // if metadata list array not associative (keys)
Parameters
Data Types

id

string

key

string, int, null

Return Type ⇒ Boolean

Last updated