芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/DataTables/AwardDataTable.php
manageAwardPermission = user()->permission('manage_award'); } /** * 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) { if ($this->manageAwardPermission == 'all') { return '
'; } return '--'; }) ->addColumn('action', function ($row) { $action = '
' . __('app.view') . '
'; if ($this->manageAwardPermission == 'all') { $action .= '
' . trans('app.edit') . '
'; $appreciationCount = 0; if (!is_null($row->appreciations)) { $appreciationCount = $row->appreciations->count(); } $action .= '
' . trans('app.delete') . '
'; } $action .= '
'; return $action; }) ->editColumn('status', function ($row) { if ($this->manageAwardPermission == 'all') { $status = '
'; $status .= '
status == 'active') { $status .= 'selected'; } $status .= 'value="active" data-content="
' . __('app.active') . '">' . __('app.active') . '
'; $status .= '
status == 'inactive') { $status .= 'selected'; } $status .= ' value="inactive" data-content="
' . __('app.inactive') . '">' . __('app.inactive') . '
'; $status .= '
'; } else { if ($row->status == 'active') { $class = 'text-light-green'; $status = __('app.active'); } else { $class = 'text-red'; $status = __('app.inactive'); } $status = '
' . $status; } return $status; }) ->addColumn('appreciation_status', function ($row) { return $row->status; }) ->editColumn( 'award_icon_id', function ($row) { return view('components.award-icon', [ 'award' => $row ]); } ) ->editColumn( 'title', function ($row) { return $row->title; } ) ->addIndexColumn() ->smart(false) ->setRowId(function ($row) { return 'row-' . $row->id; }) ->rawColumns(['check', 'status', 'action', 'award_icon_id']); } /*** * @param Notice $model * @return \Illuminate\Database\Query\Builder */ public function query(Award $model) { $model = $model->withoutGlobalScope(ActiveScope::class)->with(['awardIcon', 'appreciations'])->select('id', 'award_icon_id', 'title', 'color_code', 'status'); if (request()->searchText != '') { $model->where(function ($query) { $query->orWhere('title', 'like', '%' . request('searchText') . '%'); $query->orWhere('status', 'like', '%' . request('searchText') . '%'); }); } if (request()->status != '' && request()->status != 'all') { $model->where('status', request()->status); } return $model; } /** * Optional method if you want to use html builder. * * @return \Yajra\DataTables\Html\Builder */ public function html() { $dataTable = $this->setBuilder('appreciation-type-table', 3) ->parameters([ 'initComplete' => 'function () { window.LaravelDataTables["appreciation-type-table"].buttons().container() .appendTo("#table-actions") }', 'fnDrawCallback' => 'function( oSettings ) { $("body").tooltip({ selector: \'[data-toggle="tooltip"]\' }); $(".change-appreciation-status").selectpicker(); }', ]); 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' => '#'], __('modules.appreciations.icon') => ['data' => 'award_icon_id', 'exportable' => false, 'name' => 'award_icon_id', 'searchable' => false], __('app.title') => ['data' => 'title', 'name' => 'title', 'searchable' => true], Column::computed('status', __('app.status')) ->exportable(false) ->orderable(true) ->width(150), __('modules.appreciations.appreciationStatus') => ['data' => 'appreciation_status', 'visible' => false, 'name' => 'appreciation_status'], Column::computed('action', __('app.action')) ->exportable(false) ->printable(false) ->orderable(false) ->searchable(false) ->addClass('text-right pr-20') ]; } }