定制 romalytvynenko/eloquent-table 二次开发

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

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

romalytvynenko/eloquent-table

Composer 安装命令:

composer require romalytvynenko/eloquent-table

包简介

README 文档

README

Add folowing line to your composer.json:

"romalytvynenko/eloquent-table": "dev-master"

Add following lines to config/app.php (providers)

'Romalytvynenko\EloquentTable\EloquentTableServiceProvider'

And this part to aliases section

'EloquentTable' => 'Romalytvynenko\EloquentTable\Engine\EloquentTable'

Usage

First of all, cerate EloquentTable object.

$exampleTable = new EloquentTable('Example', $tableSettings);

Where first parameter is model name, and $tableSettings is special table settings used for current table. You could also provide some specific params, such as 'searchable' and 'preGet'. Where 'searchable' is array of columns which will be searchable (what a twist!), and 'preGet' is closure that will applied to query before all other filters (search, sort, etc.)

$tableSettings = [
    'columns' => [
        'id' => '#',
        'title' => 'Title',
        'message' => 'Message',
        'sent_at' => 'Sent',
    ],
    'sortable' => [
        'id',
        'sent_at'
    ],
    'searchable' => [
        'title'
    ],
    'preGet' => function($query) {
        /**
        * @var $query \Illuminate\Database\Query\Builder
        */
        return $query->where('type', 'group');
    },
];

And now you could render table using show method:

$exampleTable->show();

Changing column output

For changing columns output you can use closures for hooking output:

$table->columnOutput('id', function($item){
    /**
     * @var $item \Eloquent
     */
    return 'Item - ' . $item->id;
});

Where id is example of column name, and anonymous function - is the example of a function wich result will be used instead of original column value.

Your own table layout

You can easyli create your own table layout. For those purpose look at views/table.php sources, and feel free to create iyour own. You can use it passing to the show function your view name:

$exampleTable->show('admin.table');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-03-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固