Beispiel #1
0
 public function index()
 {
     if (Auth::check()) {
         // if user signed-in show another page
         //$statuses = Status::where(function($query) {
         $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(2);
         // see 'timeline/index.blade.php' for render the pagination
         //dd($statuses);
         return view('timeline.index')->with('statuses', $statuses);
     }
     return view('home');
 }
Beispiel #2
0
 public function postReply(Request $request, $statusId)
 {
     //dd($statusId);
     $this->validate($request, ["reply-{$statusId}" => 'required|max:1000'], ['required' => 'The reply body is required']);
     //dd('all okay');
     $status = Status::notReply()->find($statusId);
     if (!$status) {
         return redirect()->route('home');
     }
     if (!Auth::user()->isFriendsWith($status->user) && Auth::user()->id !== $status->user->id) {
         // not reply to ourself status
         return redirect()->route('home');
     }
     $reply = Status::create(['body' => $request->input("reply-{$statusId}")])->user()->associate(Auth::user());
     $status->replies()->save($reply);
     return redirect()->back();
 }