🍟Get Metadata

πŸ”₯ getMetadata

Get all metadata records associated with the model as an array

// Syntax
$model->getMetadata(): array

Example Usage


// If metadataNameIdEnabled is true, each metadata record will include its ID
class Post extends Model
{
    use HasManyMetadata;
    
    public $metadataNameIdEnabled = true;
    public $metadataNameId = 'id';
    ...........
}

$post->getMetadata();
/** will return:
* [
*     [
*        'id' => '01jj9s16xcze6byv94fv2f6gc5',   // <<<---------
*        'theme' => 'dark',
*        'language' => 'Arabic',
*     ],
*     [
*        'id' => '01jj9rwvm0g3sypyyb91v5x2gz',   // <<<---------
*        'theme' => 'light',
*        'language' => 'English',
*     ],
* ]
*/
circle-info

Read more for append id Custom Append ID with Run Time


πŸ”₯ getMetadataCollection

circle-check


πŸ”₯ getMetadataById

Get a specific metadata record using its ID.

Retrieves metadata values from the metadata column. If keys are provided only the specified keys will be returned.

Example Usage Without Keys Parameter

Example Usage With Keys Parameter

Parameters
Data Types

id

string

keys

array, Collection, string, int, null

circle-info

Return Type β‡’ array


πŸ”₯ getKeyMetadataById

Get a single value from a metadata record by its ID and key.

Example Usage

Parameters
Data Types

id

string

key

string, int

circle-info

Return Type β‡’ array, string, int, float, bool, null

Last updated