/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $data = $request->all(); $data['user_id'] = \Auth::user()->id; $comment = new Comment($data); $status = Status::find($data['commentable_id']); $status->comments()->save($comment); return \Redirect::back(); }
public function store(Request $request) { //dd($request->file('file')); $file = $request->file('file'); $name = time() . $file->getClientOriginalName(); $file->move('photos', $name); $data = $request->all(); $data['user_id'] = \Auth::user()->id; $photo = new Photo($data); $photo['photo_path'] = "/photos/{$name}"; $status = Status::find($data['phototable_id']); $status->photos()->save($photo); return 'Working on it'; }
/** * Get the feed for a user. * * @param User $user * @return mixed */ public function getFeedForUser(User $user) { $userIds = $user->followedUsers()->lists('followed_id'); $userIds[] = $user->id; return Status::with('comments')->whereIn('user_id', $userIds)->latest()->get(); }