芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/DataTables/ClientContactsDataTable.php
viewClientPermission = user()->permission('view_client_contacts'); $this->editClientPermission = user()->permission('edit_client_contacts'); $this->deleteClientPermission = user()->permission('delete_client_contacts'); } /** * 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 = '
'; if ($this->editClientPermission == 'all' || ($this->editClientPermission == 'added' && user()->id == $row->added_by) || ($this->editClientPermission == 'both' && user()->id == $row->added_by)) { $action .= '
' . trans('app.edit') . '
'; } if ($this->deleteClientPermission == 'all' || ($this->deleteClientPermission == 'added' && user()->id == $row->added_by) || ($this->deleteClientPermission == 'both' && user()->id == $row->added_by)) { $action .= '
' . trans('app.delete') . '
'; } $action .= '
'; return $action; }) ->editColumn( 'contact_name', function ($row) { return $row->contact_name; } ) ->editColumn( 'title', function ($row) { return $row->title; } ) ->editColumn( 'created_at', function ($row) { return Carbon::parse($row->created_at)->translatedFormat($this->company->date_format); } ) ->addIndexColumn() ->smart(false) ->setRowId(function ($row) { return 'row-' . $row->id; }) ->rawColumns(['contact_name', 'action', 'check']); } /** * @param ClientContact $model * @return ClientContact|\Illuminate\Database\Eloquent\Builder */ public function query(ClientContact $model) { $request = $this->request(); return $model->where('user_id', $request->clientID); } /** * Optional method if you want to use html builder. * * @return \Yajra\DataTables\Html\Builder */ public function html() { $dataTable = $this->setBuilder('clients-table') ->parameters([ 'initComplete' => 'function () { window.LaravelDataTables["clients-table"].buttons().container() .appendTo( "#table-actions") }', 'fnDrawCallback' => 'function( oSettings ) { // }', /* 'buttons' => ['excel'] */ ]); if (canDataTableExport()) { $dataTable->buttons(Button::make(['extend' => 'excel', 'text' => '
' . trans('app.exportExcel')])); } return $dataTable; } /** * 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, 'title' => '#'], __('app.title') => ['data' => 'title', 'name' => 'title', 'title' => __('app.title')], __('app.name') => ['data' => 'contact_name', 'name' => 'contact_name', 'title' => __('app.name')], __('app.email') => ['data' => 'email', 'name' => 'email', 'title' => __('app.email')], __('app.phone') => ['data' => 'phone', 'name' => 'phone', 'title' => __('app.phone')], __('app.createdAt') => ['data' => 'created_at', 'name' => 'created_at', 'title' => __('app.createdAt')], Column::computed('action', __('app.action')) ->exportable(false) ->printable(false) ->orderable(false) ->searchable(false) ->addClass('text-right pr-20') ]; } }