1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| <?php
namespace App\DataTables;
use App\Models\CahierCharge;
use Yajra\DataTables\Services\DataTable;
use Yajra\DataTables\EloquentDataTable;
use Yajra\DataTables\Html\Column;
class CahierChargeDataTable extends DataTable
{
/**
* Build DataTable class.
*
* @param mixed $query Results from query() method.
* @return \Yajra\DataTables\DataTableAbstract
*/
public function dataTable($query)
{
$dataTable = new EloquentDataTable($query);
return $dataTable->addColumn('action', 'cahier_charges.datatables_actions')
->addColumn('LIBELLE_SIGNE_QUALITE', function(CahierCharge $cahier) {
return $cahier->idSigneQualite->LIBELLE_SIGNE_QUALITE;
}
);
}
/**
* Get query source of dataTable.
*
* @param \App\Models\CahierCharge $model
* @return \Illuminate\Database\Eloquent\Builder
*/
public function query(CahierCharge $model)
{
return $model->newQuery();
}
/**
* Optional method if you want to use html builder.
*
* @return \Yajra\DataTables\Html\Builder
*/
public function html()
{
return $this->builder()
->columns($this->getColumns())
->minifiedAjax()
->addAction(['width' => '120px', 'printable' => false, 'title' => __('crud.action')])
->parameters([
'dom' => 'Bfrtip',
'stateSave' => true,
'order' => [[0, 'desc']],
'buttons' => [
[
'extend' => 'create',
'className' => 'btn-primary-table btn btn-default btn-sm no-corner',
'text' => '<i class="fa fa-plus"></i> ' .__('auth.app.create').''
],
[
'extend' => 'export',
'className' => 'btn-primary-table btn btn-default btn-sm no-corner',
'text' => '<i class="fa fa-download"></i> ' .__('auth.app.export').''
],
[
'extend' => 'print',
'className' => 'btn-primary-table btn btn-default btn-sm no-corner',
'text' => '<i class="fa fa-print"></i> ' .__('auth.app.print').''
],
[
'extend' => 'reset',
'className' => 'btn-primary-table btn btn-default btn-sm no-corner',
'text' => '<i class="fa fa-undo"></i> ' .__('auth.app.reset').''
],
[
'extend' => 'reload',
'className' => 'btn-primary-table btn btn-default btn-sm no-corner',
'text' => '<i class="fa fa-refresh"></i> ' .__('auth.app.reload').''
],
],
'language' => [
'url' => url('../resources/lang/fr/DataTables/French.json'),
],
]);
}
/**
* Get columns.
*
* @return array
*/
protected function getColumns()
{
return [
'LIBELLE_CAHIER_CHARGE' => new Column(['title' => __('models/cahierCharges.fields.LIBELLE_CAHIER_CHARGE'), 'data' => 'LIBELLE_CAHIER_CHARGE']),
'LIBELLE_SIGNE_QUALITE' => new Column(['title' => __('models/cahierCharges.fields.LIBELLE_SIGNE_QUALITE'), 'data' => 'LIBELLE_SIGNE_QUALITE']),
'DATE_CAHIER_CHARGE' => new Column(['title' => __('models/cahierCharges.fields.DATE_CAHIER_CHARGE'), 'data' => 'DATE_CAHIER_CHARGE']),
'FICHIER_CAHIER_CHARGE' => new Column(['title' => __('models/cahierCharges.fields.FICHIER_CAHIER_CHARGE'), 'data' => 'FICHIER_CAHIER_CHARGE'])
];
}
/**
* Get filename for export.
*
* @return string
*/
protected function filename()
{
return 'cahier_chargesdatatable_' . time();
}
} |
Partager