43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Datatables\Admin\Shop;
|
|
|
|
use App\Datatables\ParentDataTable as DataTable;
|
|
use App\Models\Shop\Customer;
|
|
use Yajra\DataTables\Html\Column;
|
|
|
|
class CustomersDataTable extends DataTable
|
|
{
|
|
public $model_name = 'customers';
|
|
|
|
public function query(Customer $model)
|
|
{
|
|
$model = $model->with('addresses');
|
|
$model = self::filterBySaleChannel($model);
|
|
|
|
return $this->buildQuery($model);
|
|
}
|
|
|
|
public static function filterBySaleChannel($model, $sale_channel_id = false)
|
|
{
|
|
$sale_channel_id = $sale_channel_id ? $sale_channel_id : self::isFilteredByField('sale_channel_id');
|
|
|
|
return $sale_channel_id ? $model->bySaleChannel($sale_channel_id) : $model;
|
|
}
|
|
|
|
protected function getColumns()
|
|
{
|
|
return [
|
|
Column::make('company')->title('Société'),
|
|
Column::make('last_name')->title('Nom'),
|
|
Column::make('first_name')->title('Prénom'),
|
|
Column::make('address')->title('Adresse'),
|
|
Column::make('zipcode')->title('Code postal'),
|
|
Column::make('city')->title('Ville'),
|
|
Column::make('phone')->title('Téléphone'),
|
|
Column::make('email')->title('Email'),
|
|
$this->makeColumnButtons(),
|
|
];
|
|
}
|
|
}
|