コード例 #1
0
 /**
  * Display a listing of reportfields
  *
  * @return Response
  */
 public function index($report_id)
 {
     if (!ReportField::canList()) {
         return $this->_access_denied();
     }
     if (Request::ajax()) {
         $users_under_me = Auth::user()->getAuthorizedUserids(ReportField::$show_authorize_flag);
         if (empty($users_under_me)) {
             $reportfields = ReportField::whereNotNull('report_fields.created_at');
         } else {
             $reportfields = ReportField::whereIn('report_fields.user_id', $users_under_me);
         }
         $reportfields->where('report_id', $report_id);
         $reportfields = $reportfields->select(['report_fields.id', 'report_fields.order', 'report_fields.name', 'report_fields.label', 'report_fields.type', 'report_fields.options', 'report_fields.default', 'report_fields.id as actions']);
         $report = Report::findOrFail($report_id);
         return Datatables::of($reportfields)->edit_column('actions', function ($reportfield) use($report_id) {
             $actions = [];
             $actions[] = $reportfield->canShow() ? link_to_action('ReportFieldsController@show', 'Show', [$report_id, $reportfield->id], ['class' => 'btn btn-xs btn-primary']) : '';
             $actions[] = $reportfield->canUpdate() ? link_to_action('ReportFieldsController@edit', 'Update', [$report_id, $reportfield->id], ['class' => 'btn btn-xs btn-default']) : '';
             $actions[] = $reportfield->canDelete() ? Former::open(action('ReportFieldsController@destroy', [$report_id, $reportfield->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);
         })->edit_column('type', function ($reportfield) use($report) {
             return $report->fieldTypes[$reportfield->type];
         })->edit_column('options', function ($reportfield) {
             return nl2br($reportfield->options);
         })->remove_column('id')->make();
         return Datatables::of($reportfields)->make();
     }
     Asset::push('js', 'datatables');
     return View::make('reportfields.index', compact('report_id'));
 }