1. Go to this page and download the library: Download samvaughton/ldt 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/ */
samvaughton / ldt example snippets
$customers = \Customer::select('id', 'name', 'email', 'phone', 'date_registered');
$dth = new DataTable(
new LaravelBuilder($customers),
new Request(\Input::all()),
array(
new Column('id'),
new Column('name', array('searchable' => true)),
new Column('email', array('searchable' => true)),
new Column('phone'),
new Column('date_registered', array(
'rowProcessor' => new \DateColumnProcessor()
)),
new Column('actions', array(
'type' => Column::TYPE_STATIC,
'rowProcessor' => function($value, $row, $originalRow) {
return sprintf(
'<a href="/customer/edit/%s">Edit</a>',
$row['id']
);
}
)
)
);
return $dth->make();
$query = DB::table('customers')->select('customers.name AS customerName');
$dth = new DataTable(
new LaravelBuilder($customers),
new Request(\Input::all()),
array(
new Column(array('customerName', 'customers.name'), array(
'searchable' => true
))
)
);
namespace \Samvaughton\Ldt;
class ExampleColumnProcessor implements RowProcessorInterface
{
/**
* This will simply append the date to the column.
*/
public function run($value, $row, $originalRow)
{
return sprintf("%s - %s", $value, date("Y-m-d"));
}
}
new Column('date', array(
'type' => Column::TYPE_STATIC,
'rowProcessor' => new \Samvaughton\Ldt\ExampleColumnProcessor
)