imade/datatable-model 问题修复 & 功能扩展

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

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

imade/datatable-model

最新稳定版本:v1.0

Composer 安装命令:

composer require imade/datatable-model

包简介

A dedicated class (model) to configure Chumper's Datatable package for Laravel (https://github.com/Chumper/Datatable) to keep your controllers as clean as possible.

README 文档

README

This is a laravel 5 package for the server and client side of datatables at http://datatables.net/

A dedicated class (model) to configure Datatables.net for Laravel to keep your controllers as clean as possible.

##Example

Your Userscontroller:

class UsersController extends \BaseController {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		$table = new UserDatatable();

		if($table->dataRequest()) return $table->data();

		return View::make('resource.index')->withTable($table);
	}
}

Dedicated UserDatatable. This class is required to extend "Imade\Datatable\DatatableModel". The two methods "data" and "table" are required.

	use Imade\Datatable\DatatableModel;

	class UserDatatable extends DatatableModel
	{
		public $columns = array(
			'id' => '#',
			'name' => 'Naam',
			'email' => 'E-mail'
		);


		public function data()
		{
			$query = User::select( array_keys($this->columns) );

			return Datatable::query($query)
				->showColumns( array_keys($this->columns) )
				->make();
		}


		public function table()
		{
			return Datatable::table()
				->addColumn( array_values($this->columns) );
		}
	}

##Install

  1. Install Datatable on: https://github.com/Chumper/Datatable
  2. Require Imade/Datatable in your composer.json:
	"imade/datatable-model": "dev-master"

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-08-04