ironshark/laravel-extendable 问题修复 & 功能扩展

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

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

ironshark/laravel-extendable

最新稳定版本:v1.0.10

Composer 安装命令:

composer require ironshark/laravel-extendable

包简介

Traits for Laravel to add and manage custom Eloquent model fields.

README 文档

README

License Downloads Version-stable

How to install

Composer Install

composer require ironshark/laravel-extendable

Laravel Service Provider

Add service provider in app/config/app.php

'providers' => [
    IronShark\Extendable\ExtendableServiceProvider::class,
];

Publish configs, templates and run migrations.

php artisan vendor:publish --provider="IronShark\Extendable\ExtendableServiceProvider"
php artisan migrate

Usage

Add traits

Add model trait to models, where you want to use custom fields.

class Article extends \Illuminate\Database\Eloquent\Model {
    use IronShark\Extendable\ModelTrait;
}

Config fields

Use app/config/custom-fields.php to configure your fields.

return [
    'App\Room' => [                                                     // model name
        'light' => [                                                    // field name
            'title' => 'Light',                                         // field title (can be used in views)
            'type' => \IronShark\Extendable\CustomFieldType::Radio,     // field type
            'options' => [                                              // possible values/labels
                0 => 'Off',
                1 => 'On'
            ],
            'default' => 1                                              // default value
        ]
    ]
];

Assign/retrieve customfield values

Assign custom field values as regular values.

$data = [
    'title' => 'Awesome Article!!!', // regular field
    'recomended' => 1                // custom filed     
];

$article = new Article();
$article->fill($data);
$article->save();

Retrieve custom field values.

$article = Article::find(1);
$article->recomended->value; // 1
echo $article->recomended;   // 1

Field types

FieldType DB DataType Example
CustomFieldType::String VARCHAR(255) Lorem
CustomFieldType::Text TEXT Lorem Ipsum...
CustomFieldType::Select VARCHAR(255) en_us
CustomFieldType::Radio VARCHAR(255) off
CustomFieldType::Checkbox VARCHAR(255) 0
CustomFieldType::DateTime TIMESTAMP 2015-01-19 03:14:07

统计信息

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

GitHub 信息

  • Stars: 24
  • Watchers: 10
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固