Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 1, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 1, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 1, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 1, 2025

      7 MagSafe accessories that I recommend every iPhone user should have

      June 1, 2025

      I replaced my Kindle with an iPad Mini as my ebook reader – 8 reasons why I don’t regret it

      June 1, 2025

      Windows 11 version 25H2: Everything you need to know about Microsoft’s next OS release

      May 31, 2025

      Elden Ring Nightreign already has a duos Seamless Co-op mod from the creator of the beloved original, and it’ll be “expanded on in the future”

      May 31, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Student Record Android App using SQLite

      June 1, 2025
      Recent

      Student Record Android App using SQLite

      June 1, 2025

      When Array uses less memory than Uint8Array (in V8)

      June 1, 2025

      Laravel 12 Starter Kits: Definite Guide Which to Choose

      June 1, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Photobooth is photobooth software for the Raspberry Pi and PC

      June 1, 2025
      Recent

      Photobooth is photobooth software for the Raspberry Pi and PC

      June 1, 2025

      Le notizie minori del mondo GNU/Linux e dintorni della settimana nr 22/2025

      June 1, 2025

      Rilasciata PorteuX 2.1: Novità e Approfondimenti sulla Distribuzione GNU/Linux Portatile Basata su Slackware

      June 1, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Manage Metadata on Laravel Eloquent Models with JSON Support

    Manage Metadata on Laravel Eloquent Models with JSON Support

    January 9, 2025

    Manage Metadata on Laravel Eloquent Models with JSON Support

    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 WaadMetadataTraitsHasManyMetadata;
    
    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.

    Hostinger

    The post Manage Metadata on Laravel Eloquent Models with JSON Support appeared first on Laravel News.

    Join the Laravel Newsletter to get all the latest
    Laravel articles like this directly in your inbox.

    Source: Read More 

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleTight Mode: Why Browsers Produce Different Performance Results
    Next Article Global View Data Management in Laravel

    Related Posts

    Artificial Intelligence

    Markus Buehler receives 2025 Washington Award

    June 1, 2025
    Artificial Intelligence

    LWiAI Podcast #201 – GPT 4.5, Sonnet 3.7, Grok 3, Phi 4

    June 1, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    3 ways test impact analysis optimizes testing in Agile sprints

    Tech & Work

    Researchers from NYU and the University of Maryland Unveil an Artificial Intelligence Framework for Understanding and Extracting Style Descriptors from Images

    Development

    7 Best Free and Open Source UPnP Media Servers

    Development

    Here’s How to Enable AI Actions in File Explorer in Windows 11

    Operating Systems

    Highlights

    Error’d: Pennies From Heaven

    July 19, 2024

    Adrian M. lit up this blooper for us. “Apparently Siemens Mobility wasn’t satisfied that a…

    Why Java endures: The foundation of modern enterprise development

    March 11, 2025

    Building interactive agents in video game worlds

    May 27, 2025

    NUMOZYLOD Malware Distributed Through Popular Searches

    August 20, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.