芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/DataTables/ClientNotesDataTable.php
editClientNotePermission = user()->permission('edit_client_note'); $this->deleteClientNotePermission = user()->permission('delete_client_note'); $this->viewClientNotePermission = user()->permission('view_client_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 ($row->ask_password == 1) { $action .= '
' . __('app.view') . '
'; } else { $action .= '
' . __('app.view') . '
'; } if ($this->editClientNotePermission == 'all' || ($this->editClientNotePermission == 'added' && user()->id == $row->added_by) || ($this->editClientNotePermission == 'both' && user()->id == $row->added_by)) { $action .= '
' . trans('app.edit') . '
'; } if ($this->deleteClientNotePermission == 'all' || ($this->deleteClientNotePermission == 'added' && user()->id == $row->added_by) || ($this->deleteClientNotePermission == 'both' && user()->id == $row->added_by)) { $action .= '
' . trans('app.delete') . '
'; } $action .= '
'; return $action; }) ->editColumn('title', function ($row) { if ($row->ask_password == 1) { return '
' . $row->title . '
'; } else { return '
' . $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 ClientNote $model * @return ClientNote|\Illuminate\Database\Eloquent\Builder */ public function query(ClientNote $model) { $request = $this->request(); $notes = $model->where('client_notes.client_id', $request->clientID); $notes->leftJoin('client_user_notes', 'client_user_notes.client_note_id', '=', 'client_notes.id'); if (in_array('client', user_roles())) { $notes->where(function ($query) { return $query->where('client_notes.type', 0) ->orWhere('client_notes.is_client_show', 1); }); } elseif (!in_array('admin', user_roles())) { if ($this->viewClientNotePermission == 'added') { $notes->where(function ($query) { return $query->where('client_notes.added_by', user()->id) ->orWhere('client_notes.type', 0); }); } elseif ($this->viewClientNotePermission == 'owned') { $notes->where(function ($query) { return $query->where('client_user_notes.user_id', user()->id) ->orWhere('client_notes.type', 0); }); } elseif ($this->viewClientNotePermission == 'both') { $notes->where(function ($query) { return $query->where('client_user_notes.user_id', user()->id) ->orWhere('client_notes.type', 0) ->orWhere('client_notes.added_by', user()->id); }); } } if (!is_null($request->searchText)) { $notes->where('client_notes.title', 'like', '%' . request('searchText') . '%'); } $notes->select('client_notes.*')->groupBy('client_notes.id'); return $notes; } /** * Optional method if you want to use html builder. * * @return \Yajra\DataTables\Html\Builder */ public function html() { $dataTable = $this->setBuilder('client-notes-table', 2) ->parameters([ 'initComplete' => 'function () { window.LaravelDataTables["client-notes-table"].buttons().container() .appendTo("#table-actions") }', 'fnDrawCallback' => 'function( oSettings ) { // }', ]); 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.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') ]; } }