芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/public_html/app/DataTables/CustomerDataRemovalDataTable.php
format('Y-m-d'); $status = LeadStatus::get(); return datatables() ->eloquent($query) ->addIndexColumn() ->addColumn('action', function ($row) { $action = '
' . __('app.approve') . '
'; $action .= '
' . __('app.reject') . '
'; return $action; }) ->addColumn('status', function ($row) use ($status) { if ($row->status == 'pending') { $status = '
' . __('app.pending') . '
'; } elseif ($row->status == 'approved') { $status = '
' . __('app.approved') . '
'; } elseif ($row->status == 'rejected') { $status = '
' . __('app.rejected') . '
'; } return $status; }) ->editColumn( 'created_at', function ($row) { return Carbon::parse($row->created_at)->format($this->company->date_format); } ) ->rawColumns(['status', 'action', 'status']); } /** * Get query source of dataTable. * @param RemovalRequest $model * @return \Illuminate\Database\Query\Builder */ public function query(RemovalRequest $model) { return $model->select('id', 'name', 'created_at', 'status', 'description'); } /** * Optional method if you want to use html builder. * * @return \Yajra\DataTables\Html\Builder */ public function html() { return $this->builder() ->setTableId('removal-request-customer') ->columns($this->getColumns()) ->minifiedAjax() ->orderBy(1) ->destroy(true) ->responsive(true) ->serverSide(true) ->stateSave(true) ->processing(true) ->dom($this->domHtml) ->language(__('app.datatable')) ->parameters([ 'initComplete' => 'function () { window.LaravelDataTables["removal-request-customer"].buttons().container() .appendTo("#table-actions") }', 'fnDrawCallback' => 'function( oSettings ) { $("body").tooltip({ selector: \'[data-toggle="tooltip"]\' }); $(".statusChange").selectpicker(); }', ]) ->buttons(Button::make(['extend' => 'excel', 'text' => '
' . trans('app.exportExcel')])); } /** * Get columns. * * @return array */ protected function getColumns() { return [ __('app.id') => ['data' => 'id', 'name' => 'id', 'visible' => false, 'exportable' => false, 'title' => __('app.id')], '#' => ['data' => 'DT_RowIndex', 'orderable' => false, 'searchable' => false, 'visible' => false], __('app.name') => ['data' => 'name', 'name' => 'name', 'title' => __('app.name')], __('app.description') => ['data' => 'description', 'name' => 'description', 'title' => __('app.description')], __('app.createdOn') => ['data' => 'created_at', 'name' => 'created_at', 'title' => __('app.createdOn')], __('app.status') => ['data' => 'status', 'name' => 'status', 'exportable' => false, 'title' => __('app.status')], Column::computed('action', __('app.action')) ->exportable(false) ->printable(false) ->orderable(false) ->searchable(false) ->width(200) ->addClass('text-right pr-20') ]; } /** * Get filename for export. * * @return string */ protected function filename() { return 'leads_' . date('YmdHis'); } public function pdf() { set_time_limit(0); if ('snappy' == config('datatables-buttons.pdf_generator', 'snappy')) { return $this->snappyPdf(); } $pdf = app('dompdf.wrapper'); $pdf->loadView('datatables::print', ['data' => $this->getDataForPrint()]); return $pdf->download($this->getFilename() . '.pdf'); } }