devmi/datatables 问题修复 & 功能扩展

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

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

devmi/datatables

Composer 安装命令:

composer require devmi/datatables

包简介

Super useful package for managing your database from an admin panel.

README 文档

README

Useful package for managing your database from an admin panel.

Installation

Step 1: Composer

From the command line, run:

composer require devmi/datatables

Step 2: Service Provider

If you're using laravel >5.5 skip to the next step.

Open config/app.php and within the providers array:

Devmi\Datatables\DataTableServiceProvider::class

Step 3: Controller

For this package to function properly, you must create a controller extends our base DataTableController.

e.g:

php artisan make:controller UserController

then, you must implement the abstract builder function

use App\User;
use Devmi\Datatables\Controllers\DatatableController;


class UserController extends DatatableController
{
    public function builder()
    {
        return User::query();
    }

    //...
}

Step 4: Route

Simply add resources route.

Open routes/web.php , add:

Route::resource('users', 'UserController');

Step 5: vendor puslish

Now you must publish the vue compenents and register it in order to use it.

php artisan vendor:publish --tag=devmi

open resources/assets/js/app.js and register the component

Vue.component('data-table', require('./vendor/devmi/DataTable.vue'));

you find the file under resources/assets/js/vendor/devmi/DataTable.vue , you customize it.

Usage

Now you can visit www.domain.com/admin/users

'users' is you table name.

Imgur

  • Repeat step 3 & step 4 for your other model.

Notice

You must to install ES6 spread operator in order to use this package properly

npm install --save-dev babel-plugin-transform-object-rest-spread

then, create .babelrc file from you command line

echo '{ "plugins": ["transform-object-rest-spread"] }' > .babelrc

Now compile your asset running

npm run dev

Extra

Example:

You can override the following functions and variables for your need

/**
 * Allows admin to add new record on database
 */

$allowCreation: Bool
public function getDisplayableColumns()
{
    return ['columns', 'you', 'need', 'to', 'display'];
}
public function getUpdatableColumns()
{
    return ['updateable', 'columns'];
}
public function store(Request $request)
{
    // Add validation for example
    parent::store($request);
}
public function update($id, Request $request)
{
    // Add validation for example
    parent::update($id, $request);
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固