-
Notifications
You must be signed in to change notification settings - Fork 1
Create a Datagrid
Patrick Samson edited this page Feb 19, 2016
·
2 revisions
You could create a folder to keep your Datagrid classes organized. Something like /app/Datagrids
.
Create the UsersDatagrid.php
file below.
<?php
namespace App\Datagrids;
use Lykegenes\DatagridBuilder\Datagrid;
class UsersDatagrid extends Datagrid
{
public function buildDatagrid()
{
$this->add('name', [
// This will be the title of this column.
'label' => 'Full Name',
])
->add('email')
->add('phone', [
'attr' => [
// We can add a prefix or suffix like this.
'data-formatter' => 'phone: %s',
],
])
->add('created_at', [
'label' => 'Created At',
'attr' => [
// Use the included formatters or create your own (in Javascript).
'data-formatter' => 'DatagridBuilder.datetimeFormatter',
],
])
->add('commands', [
'attr' => [
// Columns do not have to be bound to any data or field from the model.
// This will add View/Edit/Delete buttons, using the User ID of each row.
'data-formatter' => 'DatagridBuilder.commands',
],
]);
}
}