コード例 #1
0
 public function getName()
 {
     $badge = Badge::find($this->badge_id);
     return $badge->name;
 }
コード例 #2
0
 /**
  * Show a list of all badges formatted for Datatables.
  *
  * @param Request    $request
  * @param Datatables $dataTable
  *
  * @return Datatables JsonResponse
  */
 public function data(Request $request, Datatables $dataTable)
 {
     // Disable this query if isn't AJAX
     if (!$request->ajax()) {
         abort(400);
     }
     $badges = Badge::select(['id', 'name', 'amount_needed', 'active'])->orderBy('name', 'ASC');
     return $dataTable->of($badges)->addColumn('image', function (Badge $badge) {
         $badge = Badge::find($badge->id);
         return '<img src="' . $badge->image->url('small') . '" width="64" class="img-thumbnail" />';
     })->editColumn('active', function (Badge $badge) {
         return $badge->active ? trans('general.yes') : trans('general.no');
     })->addColumn('actions', function (Badge $badge) {
         return view('admin/partials.actions_dd', ['model' => 'badges', 'id' => $badge->id])->render();
     })->removeColumn('id')->make(true);
 }