From 62f244e9219b8c7399a6526dd290fb5e6ea78c17 Mon Sep 17 00:00:00 2001 From: Matthew Machuga Date: Tue, 11 Feb 2014 21:14:10 -0500 Subject: [PATCH] Add beginning stages for API endpoints into Lio data discovery/aggregation/bot integration --- .../Api/Forum/ForumThreadsController.php | 29 +++++++++++++++++++ app/routes.php | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 app/controllers/Api/Forum/ForumThreadsController.php diff --git a/app/controllers/Api/Forum/ForumThreadsController.php b/app/controllers/Api/Forum/ForumThreadsController.php new file mode 100644 index 000000000..6e7806c8a --- /dev/null +++ b/app/controllers/Api/Forum/ForumThreadsController.php @@ -0,0 +1,29 @@ +threads = $threads; + $this->tags = $tags; + } + + public function getIndex($status = '') + { + $threadCount = Input::get('take', $this->threadsPerPage); + $tags = $this->tags->getAllTagsBySlug(Input::get('tags')); + $threads = $this->threads->getByTagsAndStatusPaginated($tags, $status, $threadCount); + + // We want the newest threads to come out in chronological order + return $threads->getCollection()->reverse(); + } +} diff --git a/app/routes.php b/app/routes.php index ccdc709e4..cdc4fb224 100755 --- a/app/routes.php +++ b/app/routes.php @@ -88,6 +88,8 @@ Route::get('forum/{slug}/reply/{commentId}', 'ForumRepliesController@getReplyRedirect'); Route::get('forum/{slug}', ['before' => '', 'uses' => 'ForumThreadsController@getShowThread']); +Route::get('api/forum', 'Api\ForumThreadsController@getIndex'); + // admin Route::group(['before' => 'auth', 'prefix' => 'admin'], function() {