public function reply_list() { $topic_id = Input::get('topic_id'); $topic = Topic::findOrFail($topic_id); $replies = $topic->getRepliesWithLimit(10); $topic_title = $topic->title; return View::make('pages.reply_list', compact('replies', 'topic_title')); }
public function answer($tid = null) { if (empty($tid)) { return Response::json(['error' => true, 'message' => 'No topic id'], 404); } try { $t = Topic::findOrFail($tid); } catch (Exception $e) { return Response::json(['error' => true, 'message' => 'Topic not found'], 404); } $data = Input::only(['author', 'message']); $new = new TopicAnswer(); $new->tid = $tid; $new->fill($data); $new->place = Input::has('api') ? 'api' : 'web'; $new->save(); $new->created_at->format('d-m-Y'); return Response::json($new->toArray()); }
public function show($tid = 'all') { if ($tid == 'all') { if (Input::has('answers')) { $topics = Topic::with('answers')->get()->toArray(); } else { $topics = Topic::all(); } return Response::make(['success' => true, 'data' => $topics]); } else { try { $topic = Topic::findOrFail($tid); $topic->answers = $topic->answers->toArray(); return Response::make(['success' => true, 'data' => $topic]); } catch (Exception $e) { return Response::make(['error' => true, 'message' => 'Sorry but that topic cannot be found!', 'data' => null], 404); } } }
public function create() { foreach ($this->required as $required => $strlen) { if (!Input::has('tid')) { return Response::make(['error' => 'You must introduce a topic id to answer'], 404); } if (!Input::has($required) || strlen(Input::get($required)) < $strlen) { return Response::make(['error' => 'You must introduce a ' . $required . ' with ' . $strlen . ' of length...'], 404); } } $tid = Input::get('tid'); try { $topic = Topic::findOrFail($tid); } catch (Exception $e) { return Response::make(['error' => true, 'message' => 'Sorry but that topic cannot be found!', 'data' => null], 404); } $new = new TopicAnswer(); $new->tid = $tid; $new->fill(Input::only(['author', 'message'])); $new->place = $this->place; $new->save(); return Response::make(['success' => 'You just created a new answer!', 'answer' => $new->toArray(), 'topic' => $new->topic->toArray()], 404); }
public function destroy($id) { $topic = Topic::findOrFail($id); $topic->delete(); Flash::success(lang('Operation succeeded.')); return Redirect::route('topics.index'); }
public function destroy($id) { $topic = Topic::findOrFail($id); $this->authorOrAdminPermissioinRequire($topic->user_id); $topic->delete(); Flash::success(lang('Operation succeeded.')); return Redirect::route('topics.index'); }
public function NotifyTest() { if (!Auth::check()) { return 'login?'; } $user = Auth::user(); $Myfans = Fanssystem::FindMyFans($user->id); $topic = Topic::findOrFail(6); App::make('Phphub\\Notification\\Notifier')->newTopicsNotify($user, $topic); return 'ok'; }
public function sink($id) { $topic = Topic::findOrFail($id); $topic->order >= 0 ? $topic->decrement('order', 1) : $topic->increment('order', 1); return Redirect::route('topics.show', $topic->id); }
public function find($id) { return Topic::findOrFail($id); }
public function destroy($id) { $topic = Topic::findOrFail($id); $this->authorOrAdminPermissioinRequire($topic->user_id); $topic->delete(); Flash::success(lang('Operation succeeded.')); $url = Request::getRequestUri(); if (stripos($url, 'account') == false) { return Redirect::route('topics.index'); } else { return Redirect::route('ac_topices'); } }