九眼智能信息过滤 大数据助力产品升级解析
603
2022-10-23
Laravel-Metable:Laravel 5应用程序中处理任意数据的包
Laravel-Metable
Laravel-Metable is a package for easily attaching arbitrary data to Eloquent models for Laravel 5.6+.
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
Add the package to your Laravel app using composer
composer require plank/laravel-metable
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, ...];
Publish the config file (config/metable.php) and migration file (database/migrations/####_##_##_######_create_metable_table.php) of the package using artisan.
php artisan vendor:publish --provider="Plank\Metable\MetableServiceProvider"
Run the migrations to add the required table to your database.
php artisan migrate
Add the Plank\Metable\Metable trait to any eloquent model class that you want to be able to attach metadata to.
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.
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~