Esempio n. 1
0
 public function index()
 {
     if (Auth::check()) {
         $statuses = Status::notReply()->where(function ($query) {
             return $query->where('user_id', Auth::user()->id)->orWhereIn('user_id', Auth::user()->friends()->lists('id'));
         })->orderBy('created_at', 'desc')->paginate(10);
         return view('timeline.index')->with('statuses', $statuses);
     }
     return view('home');
 }
Esempio n. 2
0
 public function postReply(Request $request, $statusId)
 {
     $this->validate($request, ["reply-{$statusId}" => 'required|max:1000'], ['required' => 'The reply body is required.']);
     $status = Status::notReply()->find($statusId);
     if (!$status) {
         return redirect()->route('home');
     }
     if (!Auth::user()->isFriendsWith($status->user) && Auth::user()->id !== $status->user->id) {
         return redirect()->route('home');
     }
     $reply = Status::create(['body' => $request->input("reply-{$statusId}")])->user()->associate(Auth::user());
     $status->replies()->save($reply);
     return redirect()->back();
 }