芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/DataTables/DiscussionDataTable.php
deleteDiscussionPermission = user()->permission('delete_project_discussions'); } /** * Build DataTable class. * * @param mixed $query Results from query() method. * @return \Yajra\DataTables\DataTableAbstract */ public function dataTable($query) { return datatables() ->eloquent($query) ->editColumn('title', function ($row) { $lastReply = ''; if (!is_null($row->last_reply_by_id)) { $lastReply = '
' . $row->lastReplyBy->name . '
'; } $title = '
'; $title .= '
'; $title .= '
' . $row->title . '
' . $lastReply . '
'; $title .= '
'; if (count($row->replies) > 1) { $title .= __('modules.discussions.replied'); } else { $title .= __('modules.discussions.posted'); } $title .= ' ' . $row->last_reply_at->timezone(company()->timezone)->translatedFormat(company()->date_format . ' ' . company()->time_format) . '
'; $title .= '
'; $title .= '
'; $title .= '
'; $title .= '
'; $title .= '
' . count($row->replies) . '
'; $title .= '
'; $title .= '
'; $title .= '
'; $title .= '
'; if (isset($row->category)) { $title .= '
' . $row->category->name . '
'; } if ( $this->deleteDiscussionPermission == 'all' || ($this->deleteDiscussionPermission == 'added' && $row->added_by == user()->id) ) { $title .= '
' . __('app.delete') . '
'; $title .= '
'; } $title .= '
'; $title .= '
'; return $title; }) ->rawColumns(['title']); } /** * Get query source of dataTable. * @param Discussion $model * @return \Illuminate\Database\Eloquent\Builder */ public function query(Discussion $model) { $request = $this->request(); $model = $model->with(['user' => function ($query) { $query->withoutGlobalScope(ActiveScope::class); }, 'replies', 'category', 'lastReplyBy' => function ($query) { $query->withoutGlobalScope(ActiveScope::class); }]) ->select('discussions.*'); if (!is_null($request->project_id)) { $model->where('project_id', $request->project_id); } if (!is_null($request->category_id)) { $model->where('discussion_category_id', $request->category_id); } $model->orderBy('id', 'desc'); return $model; } /** * Optional method if you want to use html builder. * * @return \Yajra\DataTables\Html\Builder */ public function html() { $dataTable = $this->setBuilder('discussion-table', 0) ->parameters([ 'fnDrawCallback' => 'function( oSettings ) { $("body").tooltip({ selector: \'[data-toggle="tooltip"]\' }) }', ]); return $dataTable; } /** * Get columns. * * @return array */ protected function getColumns() { return [ __('app.title') => ['data' => 'title', 'name' => 'title', 'title' => __('app.title')] ]; } }