/** * 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')); }
/** * 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'); }