Laravel Packages

Manage Metadata on Laravel Eloquent Models with JSON Support

Published
Manage Metadata on Laravel Eloquent Models with JSON Support image

The Laravel Model Metadata package is designed to manage metadata in your Eloquent models with JSON support for multiple data types. With this package, you can easily attach, manage, and query your metadata:

use Waad\Metadata\Traits\HasManyMetadata;
 
class Post extends Model
{
use HasManyMetadata;
}
 
$post->createMetadata(['key' => 'value', 'another_key' => 'another_value']);
$post->updateMetadata('metadata_id', ['new_key' => 'new_value']);
$post->deleteMetadata('metadata_id');

This package also has convenience methods to retrieve metadata, whether your Model has one record or can have many metadata records:

// Operations for models with "has many" metadata
$metadata = $post->getMetadataById('metadata_id');
$allMetadata = $post->getMetadata();
$metadataCollection = $post->getMetadataCollection();
$searchResults = $post->searchMetadata('search_term');
 
// Operations for models with "has one" metadata
$metadata = $company->getMetadata();
$metadataCollection = $company->getMetadataCollection();

Main Features

  • Allow one model to have many metadata records
  • Allow one model to have one metadata record
  • Create, update, delete, and search metadata
  • JSON casting using the package's built-in trait
  • A polymorphic table design to attach metadata to any model

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

serpapi logo
SerpApi

The Web Search API for Your LLM and AI Applications

Visit SerpApi

The latest

View all →
Image Dominant Color and HEIC Support in Laravel 13.24 image

Image Dominant Color and HEIC Support in Laravel 13.24

Read article
Official Laravel Zed Extension: LSP for PHP & Blade image

Official Laravel Zed Extension: LSP for PHP & Blade

Read article
Laravel Head: Manage Meta Tags, Open Graph, and JSON-LD image

Laravel Head: Manage Meta Tags, Open Graph, and JSON-LD

Read article
PhpStorm 2026.2 Released image

PhpStorm 2026.2 Released

Read article
Laravel Doctor: Diagnose Your App With One Artisan Command image

Laravel Doctor: Diagnose Your App With One Artisan Command

Read article
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article