Download the PHP package augustpermana/laravel-meta-generator without Composer
On this page you can find all versions of the php package augustpermana/laravel-meta-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download augustpermana/laravel-meta-generator
More information about augustpermana/laravel-meta-generator
Files in augustpermana/laravel-meta-generator
Package laravel-meta-generator
Short Description A Laravel package to generate and manage metadata for models
License MIT
Homepage https://github.com/agus-gian/laravel-meta-generator
Informations about the package 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
- Installation
- Usage
- Attaching Metadata to a Model
- Managing Metadata
- Artisan Commands
make:metadata
metadata:clean-orphaned
- Configuration
- License
Installation
There are two ways to integrate Laravel Meta Generator into your project:
1. Via Packagist
Run the following command:
Laravel will automatically discover the service provider via package discovery. If necessary, manually add the provider in your config/app.php
:
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
:
Then run:
This configuration instructs Composer to use the specified local path for the package.
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
-
Generate Metadata Files:
Run the artisan command to set up the metadata system for an existing model. For example, for a
Book
model: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'sModels
directory. This file extends the package’s baseMetaModel
class. -
Updates the Original Model: You must manually update your original model file (e.g.,
Book.php
) to include theHasMetadata
trait. For example: - Creates a Migration: Generates a migration to create the corresponding metadata table (e.g.,
book_meta
).
- Creates a Meta Model File: Generates a new file (e.g.,
Managing Metadata
Once set up, your model gains several useful methods via the HasMetadata
trait:
-
Retrieving Metadata:
-
Setting Metadata:
-
Bulk Updating Metadata:
-
Syncing Metadata:
- Querying Models by Metadata:
Artisan Commands
make:metadata
This command sets up the metadata infrastructure for a specific model.
Usage:
What It Does:
- Generates a new meta model file in
app/Models
(e.g.,ModelNameMeta.php
). - Requires you to manually update your original model to include the
HasMetadata
trait. - Creates a migration to build the metadata table (e.g.,
model_name_meta
).
metadata:clean-orphaned
This command cleans up metadata records that no longer have an associated parent model.
Usage:
What It Does:
- Scans the metadata table for records with missing parent entries.
- Prompts for confirmation before deleting any orphaned records.
- Provides a summary of the changes performed.
Configuration
No additional configuration is required. Simply run the artisan commands as needed. Ensure that your models are located in the default directory (e.g., app/Models
) or adjust the paths accordingly if customized.
License
Laravel Meta Generator is open-sourced software licensed under the MIT license.
This documentation provides an overview of the package's functionality and usage. For more details and further customization options, please refer to the source code.
All versions of laravel-meta-generator with dependencies
laravel/framework Version >=8.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/database Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/events Version ^8.0|^9.0|^10.0|^11.0|^12.0
ext-json Version *