芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/portpulselogistics.com/Modules/Cargo/Http/DataTables/ClientsDataTable.php
eloquent($query) ->rawColumns(['action', 'select','name']) ->filterColumn('user', function($query, $keyword) { $query->where('name', 'LIKE', "%$keyword%"); $query->orWhere('email', 'LIKE', "%$keyword%"); $query->orWhere('responsible_mobile', 'LIKE', "%$keyword%"); }) ->orderColumn('name', function ($query, $order) { $query->orderBy('name', $order); }) ->addColumn('select', function (Client $model) { $adminTheme = env('ADMIN_THEME', 'adminLte'); return view($adminTheme.'.components.modules.datatable.columns.checkbox', ['model' => $model, 'ifHide' => $model->id == 0]); }) ->editColumn('branch_id', function (Client $model) { return $model->branch->name ?? "Null" ; }) ->editColumn('created_at', function (Client $model) { return date('d M, Y H:i', strtotime($model->created_at)); }) // ->editColumn('avatar', function (Staff $model) { // return ' //
//
//
//
//
//
//
'; // }) ->addColumn('user', function (Client $model) { $adminTheme = env('ADMIN_THEME', 'adminLte');return view('cargo::'.$adminTheme.'.pages.clients.columns.user', ['model' => $model]); }) ->addColumn('action', function (Client $model) { $adminTheme = env('ADMIN_THEME', 'adminLte');return view('cargo::'.$adminTheme.'.pages.clients.columns.actions', ['model' => $model, 'table_id' => $this->table_id]); }); } /** * Get query source of dataTable. * * @param Client $model * * @return Client */ public function query(Client $model, Request $request) { $query = $model->getClients($model)->newQuery(); // class filter for user only $client_filter = new ClientFilter($query, $request); $query = $client_filter->filterBy($this->filters); return $query; } /** * Optional method if you want to use html builder. * * @return \Yajra\DataTables\Html\Builder */ public function html() { $lang = \LaravelLocalization::getCurrentLocale(); $lang = get_locale_name_by_code($lang, $lang); return $this->builder() ->setTableId($this->table_id) ->columns($this->getColumns()) ->minifiedAjax() ->stateSave(true) ->orderBy(1) ->responsive() ->autoWidth(false) ->parameters([ 'scrollX' => true, 'dom' => 'Bfrtip', 'bDestroy' => true, 'language' => ['url' => "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/$lang.json"], 'buttons' => [ ...$this->buttonsExport(), ], ]) ->addTableClass('align-middle table-row-dashed fs-6 gy-5'); } /** * Get columns. * * @return array */ protected function getColumns() { return [ Column::computed('select') ->title('
') ->responsivePriority(-1) ->addClass('not-export') ->width(50), Column::make('id')->title(__('cargo::view.table.#'))->width(50), Column::make('user')->title(__('cargo::view.client')), Column::make('responsible_mobile')->title(__('cargo::view.table.phone')), Column::make('branch_id')->title(__('cargo::view.table.branch')), Column::make('created_at')->title(__('view.created_at')), Column::computed('action') ->title(__('view.action')) ->addClass('text-center not-export') ->responsivePriority(-1) ]; } /** * Get filename for export. * * @return string */ protected function filename() { return 'clients_'.date('YmdHis'); } /** * Transformer buttons export. * * @return string */ protected function buttonsExport() { $btns = []; foreach($this->btn_exports as $btn) { $btns[] = [ 'extend' => $btn, 'exportOptions' => [ 'columns' => 'th:not(.not-export)' ] ]; } return $btns; } }