royalcms/metable
Composer 安装命令:
composer require royalcms/metable
包简介
The Royalcms metable package.
README 文档
README
Royalcms-Metable is a package for easily attaching arbitrary data to Eloquent models for Royalcms 5.
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');
Add the Royalcms\Component\Metable\Metable trait to any eloquent model class that you want to be able to attach metadata to.
<?php namespace App; use Royalcms\Component\Database\Eloquent\Model; use Plank\Metable\Metable; class Post extends Model { use Metable; //... }
License
This package is released under the MIT license (MIT).
统计信息
- 总下载量: 58
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-04