PHP code example of imade / datatable-model

1. Go to this page and download the library: Download imade/datatable-model library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

imade / datatable-model example snippets



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);
	}
}



	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) );
		}
	}


	"imade/datatable-model": "dev-master"