/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $authID = \Auth::user()->id;
     $stories = story::where('user_id', $id)->get();
     $profile = user::where('id', $id)->get();
     $thisProfiel = user::where('id', $id)->get()->first();
     // explore trip I made
     $explore = Expedition::where('user_id', $id)->get();
     // explore trips where I'm invite too
     $invexplore = Expfriend::select('expedition_id')->where('user_id', $id)->get();
     $invexplore = $invexplore->lists('expedition_id');
     $invexploration = Expedition::whereIn('id', $invexplore)->get();
     //my friends
     $listfriends = friend::select('friend_id')->where('user_id', $id)->where('state', 1)->get();
     $listfriends = $listfriends->lists('friend_id');
     $friends = user::whereIn('id', $listfriends)->get();
     //my invited for friends
     $notmyfriends = friend::select('user_id')->where('friend_id', $id)->where('state', 0)->get();
     $notmyfriends = $notmyfriends->lists('user_id');
     $invitefriends = user::whereIn('id', $notmyfriends)->get();
     if ($id == $authID) {
         $isthisme = "yes";
     } else {
         $isthisme = "no";
     }
     return view('profile.index', compact('stories', 'isthisme', 'friends', 'invitefriends', 'thisProfiel', 'explore', 'invexploration'));
 }
 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);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateExpadition $request)
 {
     $input = $request->all();
     $creator = \Auth::user()->id;
     $expedition = new Expedition();
     $expedition->title = $input['title'];
     $expedition->location = $input['location'];
     $expedition->date = $input['date'];
     $expedition->description = $input['description'];
     $expedition->user_id = $creator;
     // image
     $expedition->save();
     $expfriends = new Expfriend();
     $expfriends->expedition_id = $expedition->id;
     $expfriends->user_id = $creator;
     $expfriends->creator_id = $creator;
     $expfriends->save();
     return redirect('story/' . $story->id . '/edit');
 }
 /**
  *@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));
 }
 /**
  * @test
  */
 public function an_expedition_gallery_is_automatically_created_when_an_expedition_is_created()
 {
     $expedition = factory(App\Expedition::class)->make();
     $this->asAnAdminUser();
     $this->visit('/admin/expeditions/create')->submitForm('Create Expedition', ['name' => $expedition->name, 'location' => $expedition->location, 'start_date' => '1982-05-20', 'about' => 'about', 'objectives' => 'objectives', 'mission' => 'mission', 'donation_goal' => 'R1000'])->seeInDatabase('expeditions', ['name' => $expedition->name, 'location' => $expedition->location]);
     $newExpedition = \App\Expedition::where('name', $expedition->name)->firstOrFail();
     $this->assertGreaterThan(0, $newExpedition->galleries->count(), 'should be at least one gallery');
 }
 public function expeditions()
 {
     $expeditions = Expedition::latest()->get();
     $page = $this->contentRepository->getPageByName('expeditions');
     return view('front.pages.expeditionsindex')->with(compact('expeditions', 'page'));
 }
 protected function getExpeditions()
 {
     return Cache::remember('home:expeditions', static::CACHE_DURATION, function () {
         return Expedition::latest()->take(4)->get();
     });
 }