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

# Forget Metadata

## 🔥 `forgetMetadataById`

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

#### Example Usage

```php

// 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 : []

```

{% hint style="info" %}
<mark style="color:green;">Return Type ⇒</mark> <mark style="color:orange;">Boolean</mark>
{% endhint %}



***



## 🔥 `forgetKeysMetadataById`

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

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

#### Example Usage

```php

// 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)

```

<table><thead><tr><th width="202">Parameters</th><th>Data Types</th></tr></thead><tbody><tr><td><mark style="color:red;">id</mark></td><td><mark style="color:purple;"><code>string</code></mark></td></tr><tr><td><mark style="color:red;">keys</mark></td><td><mark style="color:purple;"><code>array, Collection, string, int, null</code></mark></td></tr></tbody></table>

{% hint style="info" %}
<mark style="color:green;">Return Type ⇒</mark> <mark style="color:orange;">Boolean</mark>
{% endhint %}



***



## 🔥 `forgetKeyMetadataById`&#x20;

{% hint style="warning" %}
It's an Alias of the \`<mark style="color:blue;">forgetKeysMetadataById</mark>\` method used for forgetting Individual Key
{% endhint %}

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

#### Example usage

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

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

<table><thead><tr><th width="186">Parameters</th><th>Data Types</th></tr></thead><tbody><tr><td><mark style="color:red;">id</mark></td><td><mark style="color:purple;"><code>string</code></mark></td></tr><tr><td><mark style="color:red;">key</mark></td><td><mark style="color:purple;"><code>string, int, null</code></mark></td></tr></tbody></table>

{% hint style="info" %}
<mark style="color:green;">Return Type ⇒</mark> <mark style="color:orange;">Boolean</mark>
{% endhint %}

