定制 latevaweb/laravel-custom-properties 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

latevaweb/laravel-custom-properties

最新稳定版本:1.0.3

Composer 安装命令:

composer require latevaweb/laravel-custom-properties

包简介

Laravel trait to make add dynamic properties to Eloquent models

README 文档

README

Trait to add dynamic custom properties to Eloquent models

Scrutinizer Code Quality Code Coverage Build Status StyleCI License: MIT Laravel 6.x

Once the trait is installed on the model and migration field is added you can do these things:

$customer = new Customer; // An Eloquent model
$customer
   ->setCustomProperty('foo', 'bar')
   ->setCustomProperty('foo2', 'bar2')
   ->save();
   
$customer->hasCustomProperty('foo'); // Returns 'true'

$customer->getCustomProperty('foo'); // returns 'bar'

$customer->forgetCustomProperty('foo'); // removes field 'foo' from model array

// Don't forget to persist it!

$customer->save();

Installation

You can install the package via composer:

composer require latevaweb/laravel-custom-properties

Adding custom properties to a Model

The required steps to add custom properties to a model are:

  • First, you need to add the LaTevaWeb\CustomProperties\HasCustomProperties-trait.
  • It is required to add to your model table the field $table->json('custom_properties')->nullable();

Here's an example of a prepared model:

use Illuminate\Database\Eloquent\Model;
use LaTevaWeb\CustomProperties\HasCustomProperties;

class NewsItem extends Model
{
    use HasCustomProperties;
}

And the migration:

Schema::table('your_table', function (Blueprint $table) {
    $table->json('custom_properties')->nullable();
});

统计信息

  • 总下载量: 1.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固