2017 © Pedro Peláez
 

library laravel-metable

A package for attaching arbitrary data to Eloquent models

image

plank/laravel-metable

A package for attaching arbitrary data to Eloquent models

  • Tuesday, May 15, 2018
  • by frasmage
  • Repository
  • 7 Watchers
  • 111 Stars
  • 15,273 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 14 Forks
  • 0 Open issues
  • 8 Versions
  • 34 % Grown

The README.md

Laravel-Metable

Coveralls StyleCI Packagist, (*1)

Laravel-Metable is a package for easily attaching arbitrary data to Eloquent models., (*2)

Features

  • One-to-many polymorphic relationship allows attaching data to Eloquent models without needing to adjust the database schema.
  • Type conversion system allows data of numerous different scalar and object types to be stored and retrieved. See the documentation for the list of supported types.

Example Usage

Attach some metadata to an eloquent model, (*3)

$post = Post::create($this->request->input());
$post->setMeta('color', 'blue');

Query the model by its metadata, (*4)

$post = Post::whereMeta('color', 'blue');

Retrieve the metadata from a model, (*5)

$value = $post->getMeta('color');

Installation

  1. Add the package to your Laravel app using composer
composer require plank/laravel-metable
  1. Register the package's service provider in config/app.php. In Laravel versions 5.5 and beyond, this step can be skipped if package auto-discovery is enabled.
'providers' => [
    ...
    Plank\Metable\MetableServiceProvider::class,
    ...
];
  1. Publish the config file (config/metable.php) of the package using artisan.
php artisan vendor:publish --provider="Plank\Metable\MetableServiceProvider"
  1. Run the migrations to add the required table to your database.
php artisan migrate
  1. Add the Plank\Metable\Metable trait to any eloquent model class that you want to be able to attach metadata to.

Note: If need a more generic way to reference different Metable Model classes, you can optionally apply the Plank\Metable\MetableInterface to your models., (*6)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Plank\Metable\Metable;

class Post extends Model
{
    use Metable;

    //...
}

Documentation

The full documentation is available on ReadTheDocs., (*7)

License

This package is released under the MIT license (MIT)., (*8)

About Plank

Plank is a web development agency based in Montreal, Canada., (*9)

The Versions

15/05 2018

dev-master

9999999-dev

A package for attaching arbitrary data to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sean Fraser

15/05 2018

1.1.0

1.1.0.0

A package for attaching arbitrary data to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sean Fraser

21/08 2017

1.0.4

1.0.4.0

A package for attaching arbitrary data to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sean Fraser

21/08 2017

dev-analysis-XaNmYY

dev-analysis-XaNmYY

A package for attaching arbitrary data to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sean Fraser

21/03 2017

1.0.3

1.0.3.0

A package for attaching arbitrary data to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sean Fraser

03/02 2017

1.0.2

1.0.2.0

A package for attaching arbitrary data to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sean Fraser

30/01 2017

1.0.1

1.0.1.0

A package for attaching arbitrary data to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sean Fraser

16/01 2017

1.0.0

1.0.0.0

A package for attaching arbitrary data to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sean Fraser