public function index()
 {
     $users = User::with(['address', 'avatar', 'categories', 'club', 'role'])->get();
     return $this->respond(['data' => $this->userTransformer->transformCollection($users->all())]);
 }
 public function anglers()
 {
     $event = Event::current();
     $users = User::with(['categories', 'club'])->whereHas('weighIns', function ($query) use($event) {
         $query->where('event_id', '=', $event->id);
     })->get()->transform(function ($v) use($event) {
         $categories = null;
         if (!is_null($v->categories)) {
             foreach ($v->categories as $cat) {
                 $categories[] = ['id' => $cat['id'], 'name' => $cat['name']];
             }
         }
         $bestFish = Entry::with('species')->where('user_id', '=', $v['id'])->where('event_id', '=', $event->id)->orderBy('percentage', 'desc')->select('percentage', 'weight', 'species_id')->first();
         return ['id' => $v['id'], 'fullName' => $v['last_name'] . ' ' . $v['first_name'], 'categories' => $categories, 'club' => ['id' => $v['club']['id'], 'name' => $v['club']['name']], 'fishCount' => Entry::where('user_id', '=', $v['id'])->where('event_id', '=', $event->id)->get()->count(), 'bestFish' => ['name' => $bestFish['species']['name'], 'weight' => Helpers::fromDrams($bestFish['weight']), 'percentage' => round($bestFish['percentage']) . "%"]];
     })->toArray();
     return $this->respond(['data' => $users ?: null]);
 }
 public function index()
 {
     $skippers = User::with(['boats'])->has('boats')->get();
     return $this->respond(['data' => $this->skipperTransformer->transformCollection($skippers->all())]);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     // Use eager loading to pass address relation
     $user = User::with(['address', 'categories'])->findOrFail($id);
     $userRoles = Helpers::getUserRoles();
     $userClubs = Helpers::getUserClubs();
     $userCategories = Helpers::getUserCategories();
     // Makes sure category checkboxes are correctly checked off
     // Assigns category id to collection index
     if (!$user->categories->isEmpty()) {
         foreach ($user['categories'] as $category) {
             $user['categories'][$category->id] = $category;
         }
         unset($user['categories'][0]);
     }
     return view('admin.pages.users.edit', compact('user', 'userCategories', 'userClubs', 'userRoles'));
 }