芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/public_html/app/DataTables/LeadNotesDataTable.php
editLeadNotePermission = user()->permission('edit_lead_note'); $this->deleteLeadNotePermission = user()->permission('delete_lead_note'); } /** * Build DataTable class. * * @param mixed $query Results from query() method. * @return \Yajra\DataTables\DataTableAbstract */ public function dataTable($query) { return datatables() ->eloquent($query) ->addColumn('check', function ($row) { return '
'; }) ->addColumn('action', function ($row) { $action = '
'; $action .= '
'; if (!in_array('admin', user_roles()) && $row->ask_password == 1) { $action .= '
' . __('app.view') . '
'; } else { $action .= '
' . __('app.view') . '
'; } if ($this->editLeadNotePermission == 'all' || ($this->editLeadNotePermission == 'added' && user()->id == $row->added_by) || ($this->editLeadNotePermission == 'both' && user()->id == $row->added_by)) { $action .= '
' . trans('app.edit') . '
'; } if ($this->deleteLeadNotePermission == 'all' || ($this->deleteLeadNotePermission == 'added' && user()->id == $row->added_by) || ($this->deleteLeadNotePermission == 'both' && user()->id == $row->added_by)) { $action .= '
' . trans('app.delete') . '
'; } $action .= '
'; return $action; }) ->editColumn('title', function ($row) { if (!in_array('admin', user_roles()) && $row->ask_password == 1) { return '
' . mb_ucwords($row->title) . '
'; } else { return '
' . mb_ucwords($row->title) . '
'; } // return mb_ucwords($row->title); }) ->editColumn('type', function ($row) { if ($row->type == '0') { return '
' . __('app.public') . '
'; } else { return '
' . __('app.private') . '
'; } }) ->editColumn('id', function ($row) { return $row->id; }) ->addIndexColumn() ->smart(false) ->setRowId(function ($row) { return 'row-' . $row->id; }) ->rawColumns(['action', 'check', 'title', 'type']); } /** * @param LeadNote $model * @return LeadNote|\Illuminate\Database\Eloquent\Builder */ public function query(LeadNote $model) { $request = $this->request(); $notes = $model->where('lead_id', $request->leadID); if (in_array('lead', user_roles())) { $notes->where('type', 0); $notes->orWhere('is_lead_show', 1); } if (!in_array('admin', user_roles())) { $notes->where(function ($query) { return $query->whereHas('members', function ($query) { return $query->where('user_id', user()->id); })->where('type', 1)->orWhere('type', 0); }); } if (!is_null($request->searchText)) { $notes->where('title', 'like', '%' . request('searchText') . '%'); } return $notes; } /** * Optional method if you want to use html builder. * * @return \Yajra\DataTables\Html\Builder */ public function html() { return $this->builder() ->setTableId('lead-notes-table') ->columns($this->getColumns()) ->minifiedAjax() ->orderBy(2) ->destroy(true) ->responsive(true) ->serverSide(true) ->stateSave(true) ->processing(true) ->dom($this->domHtml) ->language(__('app.datatable')) ->parameters([ 'initComplete' => 'function () { window.LaravelDataTables["lead-notes-table"].buttons().container() .appendTo("#table-actions") }', 'fnDrawCallback' => 'function( oSettings ) { // }', ]) ->buttons(Button::make(['extend' => 'excel', 'text' => '
' . trans('app.exportExcel')])); } /** * Get columns. * * @return array */ protected function getColumns() { return [ 'check' => [ 'title' => '
', 'exportable' => false, 'orderable' => false, 'searchable' => false ], '#' => ['data' => 'DT_RowIndex', 'orderable' => false, 'searchable' => false, 'visible' => false], __('app.id') => ['data' => 'id', 'name' => 'id', 'visible' => false, 'title' => __('app.id')], __('modules.client.noteTitle') => ['data' => 'title', 'name' => 'title', 'title' => __('modules.client.noteTitle')], __('modules.client.noteType') => ['data' => 'type', 'name' => 'type', 'title' => __('modules.client.noteType')], Column::computed('action', __('app.action')) ->exportable(false) ->printable(false) ->orderable(false) ->searchable(false) ->addClass('text-right pr-20') ]; } /** * Get filename for export. * * @return string */ protected function filename() { return 'lead_note_' . 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'); } }