Beispiel #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');
 }
 public function postReply(Request $req, $statusId)
 {
     $this->validate($req, ["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' => $req->input("reply-{$statusId}")])->user()->associate(Auth::user());
     $status->replies()->save($reply);
     return redirect()->back();
 }