public function store(Request $request, $expeditionId)
 {
     $this->validate($request, ['title' => 'required|max:255', 'longitude' => 'required|numeric|between:-90,90', 'latitude' => 'required|numeric|between:-90,90']);
     $expedition = Expedition::findOrFail($expeditionId);
     $expedition->addLocation($request->all());
     return redirect('admin/expeditions/' . $expedition->id . '/locations');
 }
 public function setTeam($id, Request $request)
 {
     $teamIds = collect($request->team_member)->map(function ($item) {
         return intval($item);
     })->toArray();
     $expedition = Expedition::findOrFail($id);
     $expedition->syncTeamMembers($teamIds);
     $this->flasher->success('Team Members Set', 'The team for this expedition has been updated');
     return redirect('admin/expeditions/' . $expedition->id);
 }
 /**
  *@test
  */
 public function a_group_of_team_members_can_be_synced_as_an_expeditions_team()
 {
     $member = factory(TeamMember::class)->create();
     $expedition = factory(Expedition::class)->create();
     $expedition->addTeamMember($member->id);
     $this->assertCount(1, $expedition->teamMembers, 'should only have one team member now');
     $newMembers = factory(TeamMember::class, 3)->create();
     $expedition->syncTeamMembers($newMembers->pluck('id')->toArray());
     $expedition = Expedition::findOrFail($expedition->id);
     $this->assertCount(3, $expedition->teamMembers);
     $this->assertFalse($expedition->hasTeamMember($member));
 }