/** * Display a listing of reporteagers * * @return Response */ public function index($report_id) { if (!ReportEager::canList()) { return $this->_access_denied(); } if (Request::ajax()) { $users_under_me = Auth::user()->getAuthorizedUserids(ReportEager::$show_authorize_flag); if (empty($users_under_me)) { $reporteagers = ReportEager::whereNotNull('report_eagers.created_at'); } else { $reporteagers = ReportEager::whereIn('report_eagers.user_id', $users_under_me); } $reporteagers->where('report_id', $report_id); $reporteagers = $reporteagers->select(['report_eagers.id', 'report_eagers.name', 'report_eagers.id as actions']); return Datatables::of($reporteagers)->edit_column('actions', function ($reporteager) use($report_id) { $actions = []; $actions[] = $reporteager->canShow() ? link_to_action('ReportEagersController@show', 'Show', [$report_id, $reporteager->id], ['class' => 'btn btn-xs btn-primary']) : ''; $actions[] = $reporteager->canUpdate() ? link_to_action('ReportEagersController@edit', 'Update', [$report_id, $reporteager->id], ['class' => 'btn btn-xs btn-default']) : ''; $actions[] = $reporteager->canDelete() ? Former::open(action('ReportEagersController@destroy', [$report_id, $reporteager->id]))->class('form-inline') . Former::hidden('_method', 'DELETE') . '<button type="button" class="btn btn-xs btn-danger confirm-delete">Delete</button>' . Former::close() : ''; return implode(' ', $actions); })->remove_column('id')->make(); return Datatables::of($reporteagers)->make(); } Asset::push('js', 'datatables'); return View::make('reporteagers.index', compact('report_id')); }