PHPackages                             augustpermana/laravel-meta-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. augustpermana/laravel-meta-generator

ActiveLaravel-package

augustpermana/laravel-meta-generator
====================================

A Laravel package to generate and manage metadata for models

v1.1.6(12mo ago)019MITPHPPHP &gt;=7.3

Since Feb 22Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/agus-gian/laravel-meta-generator)[ Packagist](https://packagist.org/packages/augustpermana/laravel-meta-generator)[ Docs](https://github.com/agus-gian/laravel-meta-generator)[ RSS](/packages/augustpermana-laravel-meta-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (13)Used By (0)

Laravel Meta Generator
======================

[](#laravel-meta-generator)

Laravel Meta Generator is a powerful package that enables you to easily attach and manage metadata for your Eloquent models without modifying their primary database tables. It provides a flexible key-value system featuring automatic type detection, casting, and handy artisan commands to simplify installation and maintenance.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Attaching Metadata to a Model](#attaching-metadata-to-a-model)
    - [Managing Metadata](#managing-metadata)
- [Artisan Commands](#artisan-commands)
    - [`make:metadata`](#makemetadata)
    - [`metadata:clean-orphaned`](#metadataclean-orphaned)
- [Configuration](#configuration)
- [License](#license)

---

Installation
------------

[](#installation)

There are two ways to integrate Laravel Meta Generator into your project:

### 1. Via Packagist

[](#1-via-packagist)

Run the following command:

```
composer require augustpermana/laravel-meta-generator
```

Laravel will automatically discover the service provider via package discovery. If necessary, manually add the provider in your `config/app.php`:

```
'providers' => [
    // Other Service Providers

    August\MetaGenerator\ServiceProvider::class,
],
```

### 2. Using a Local Repository

[](#2-using-a-local-repository)

If the package isn’t published on Packagist yet, add it as a local repository. Modify your project's `composer.json`:

```
"repositories": [
    {
        "type": "path",
        "url": "../laravel-meta-table"
    }
],
```

Then run:

```
composer require augustpermana/laravel-meta-generator
```

This configuration instructs Composer to use the specified local path for the package.

---

Usage
-----

[](#usage)

Laravel Meta Generator lets you attach metadata to your models without modifying the original database tables. Once installed, you can either use the provided artisan commands or manually integrate the functionality into your models.

### Attaching Metadata to a Model

[](#attaching-metadata-to-a-model)

1. **Generate Metadata Files:**

    Run the artisan command to set up the metadata system for an existing model. For example, for a `Book` model:

    ```
    php artisan make:metadata --model=Book
    ```

    When you run this command, it performs the following actions:

    - **Creates a Meta Model File:** Generates a new file (e.g., `BookMeta.php`) in your application's `Models` directory. This file extends the package’s base `MetaModel` class.
    - **Updates the Original Model:** You must manually update your original model file (e.g., `Book.php`) to include the `HasMetadata` trait. For example:

        ```
