/** * Show the list of conversation between contributor. * * @param Request $request * @param $username * @return \Illuminate\Http\Response */ public function conversation(Request $request, $username) { /* * -------------------------------------------------------------------------- * Retrieve conversation * -------------------------------------------------------------------------- * Retrieve conversation 15 data per request, because we implement lazy * pagination via ajax so return json data when 'page' variable exist, and * return view if doesn't. */ $contributor = Contributor::whereUsername($username)->firstOrFail(); $user_id = $request->input("contributor_id"); $conversations = $this->conversation->retrieveConversation($contributor->id, Input::get('last', null), $user_id); return response()->json(['request_id' => uniqid(), 'status' => 'success', 'timestamp' => Carbon::now(), 'conversations' => $conversations]); }
/** * Show the list of conversation between contributor. * * @param Request $request * @param $username * @return \Illuminate\Http\Response */ public function conversation(Request $request, $username) { /* * -------------------------------------------------------------------------- * Retrieve conversation * -------------------------------------------------------------------------- * Retrieve conversation 15 data per request, because we implement lazy * pagination via ajax so return json data when 'page' variable exist, and * return view if doesn't. */ $contributor = Contributor::whereUsername($username)->firstOrFail(); $conversations = $this->conversation->retrieveConversation($contributor->id, Input::get('last', null)); if ((Input::get('page', false) || Input::has('last')) && $request->ajax()) { return $conversations; } else { return view('contributor.conversation', compact('contributor', 'conversations')); } }