plank/laravel-metable 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

plank/laravel-metable

最新稳定版本:6.2.0

Composer 安装命令:

composer require plank/laravel-metable

包简介

A package for attaching arbitrary data to Eloquent models

README 文档

README

Coveralls StyleCI Packagist

Laravel-Metable is a package for easily attaching arbitrary data to Eloquent models.

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

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

Query the model by its metadata

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

Retrieve the metadata from a model

$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.

<?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.

License

This package is released under the MIT license (MIT).

About Plank

Plank is a web development agency based in Montreal, Canada.

统计信息

  • 总下载量: 699.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 288
  • 点击次数: 1
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 282
  • Watchers: 8
  • Forks: 42
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-16