🚀
Model Metadata
  • Introduction V2
  • Requirements
  • Installation
  • Basics
    • Simple Usage
    • HasOneMetadata
      • 😎Use in Model
      • 🎃Create Metadata
      • 🍕Get Metadata
      • ✅Has Metadata
      • 💫Update Metadata
      • ☂️Sync Metadata
      • 💣Delete Metadata
      • 🐙Forget Metadata
    • HasManyMetadata
      • 😐Use in Model
      • 🍔Create Metadata
      • 🍟Get Metadata
      • 🥊Search Metadata
      • 📭Has Metadata
      • 🪭Update Metadata
      • ⛱️Sync Metadata
      • 🪣Delete Metadata
      • 🧽Forget Metadata
Powered by GitBook
On this page
  • 🔥 forgetMetadataById
  • 🔥 forgetKeysMetadataById
  • 🔥 forgetKeyMetadataById
  1. Basics
  2. HasManyMetadata

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

It's an Alias of the `forgetKeysMetadataById` method used for forgetting Individual Key

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

PreviousDelete Metadata

Last updated 4 months ago

🧽