diff --git a/controllers/Home.php b/controllers/Home.php
index 139f6cfe..8f255e1b 100644
--- a/controllers/Home.php
+++ b/controllers/Home.php
@@ -3,9 +3,33 @@
namespace Latchel;
use Controller;
+use Post;
+use User;
+use Comment;
class HomeController extends Controller{
public function index(){
- return view('template');
+ $posts = $this->getPosts('home');
+
+ return view('template', ['posts' = $posts]);
+ }
+
+ public static function getPosts($slug){
+ $posts = Post::where('slug', '=', $slug)->get();
+
+ foreach($posts as &$post){
+ $post->user = User::find($post->user_id);
+ }
+
+ foreach($posts as &$post){
+ $post->comments = Comment::where('post_id', '=', $post->post_id)->get();
+
+ foreach($post->comments as &$comment){
+ $comment->user = User::find($comment->user_id);
+ }
+ }
+
+ return $posts;
}
+
}
\ No newline at end of file
diff --git a/public/assets/js/app.js b/public/assets/js/app.js
index 2c56c50f..00423b21 100644
--- a/public/assets/js/app.js
+++ b/public/assets/js/app.js
@@ -1 +1,23 @@
-angular.module('CodeReviewApp', []);
\ No newline at end of file
+angular.module('CodeReviewApp', [])
+ .directive('post', [function(){
+ return {
+ restrict: 'A',
+ replace: true,
+ transclude: true,
+ template: '' +
+ '