Regarding your query, I think you have two mistakes:
- You need to append
get()
after yourwhere($condition)
- You are querying for post ids greater than your post id. Shouldn't be that an equal sign?
It should be something like this:
$likes = Like::where('post_id', '=', $post->post_id)->get();
Then, as I pointed out in my comment, I'd recommend that you do all your model related stuff in a repository class, use that class in your controller, and pass the result to the view.
Your repository class:
class PostRepository {
public function byDate()
{
// return posts by date
}
}
Your controller:
class MyAwesomeController {
protected $postRepository;
...
public function awesomeSection()
{
$posts = $this->postRepository->byDate();
return View::make('awesome.view')->with('posts' => $posts);
// or
return View::make('awesome.view', compact('posts'));
}
}
Further reading: