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

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 2, 2025

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

      June 2, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 2, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 2, 2025

      How Red Hat just quietly, radically transformed enterprise server Linux

      June 2, 2025

      OpenAI wants ChatGPT to be your ‘super assistant’ – what that means

      June 2, 2025

      The best Linux VPNs of 2025: Expert tested and reviewed

      June 2, 2025

      One of my favorite gaming PCs is 60% off right now

      June 2, 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

      `document.currentScript` is more useful than I thought.

      June 2, 2025
      Recent

      `document.currentScript` is more useful than I thought.

      June 2, 2025

      Adobe Sensei and GenAI in Practice for Enterprise CMS

      June 2, 2025

      Over The Air Updates for React Native Apps

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

      You can now open ChatGPT on Windows 11 with Win+C (if you change the Settings)

      June 2, 2025
      Recent

      You can now open ChatGPT on Windows 11 with Win+C (if you change the Settings)

      June 2, 2025

      Microsoft says Copilot can use location to change Outlook’s UI on Android

      June 2, 2025

      TempoMail — Command Line Temporary Email in Linux

      June 2, 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 

    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

    Development

    A Beginner’s Guide to Graphs — From Google Maps to Chessboards

    June 2, 2025
    Development

    How to Code Linked Lists with TypeScript: A Handbook for Developers

    June 2, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Kingdom Come: Deliverance 2 surpasses staggering new sales threshold

    News & Updates

    Mitigating risk: AWS backbone network traffic prediction using GraphStorm

    Machine Learning

    Microsoft’s ‘Avowed’ advanced access inexplicably skips Xbox Cloud Gaming in favor of NVIDIA GeForce Now, putting Xbox customers last

    News & Updates

    Windows 11 is showing more Xbox Game Pass PC ads notifications. Turn them off

    Development

    Highlights

    Linux

    VLC Developers Working on AI-Powered Real-Time Subtitles

    January 12, 2025

    Real-time AI subtitling is in the works for VLC, the phenomenally popular open-source media player.…

    Mitigating REST API Challenges with GraphQL Adoption

    June 25, 2024

    DRLQ: A Novel Deep Reinforcement Learning (DRL)-based Technique for Task Placement in Quantum Cloud Computing Environments

    July 8, 2024

    Xbox’s mobile aspirations may finally come to fruition as a U.S. judge just banned Apple from restricting developers’ payment systems on iOS

    May 1, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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