File: D:/HostingSpaces/SBogers93/fitale.nl/app/Komma/Posts/Composers/LatestPostsComposer.php
<?php
/**
* Short description for the file.
*
* @author Tim Van Samang <timvansamang@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
namespace Komma\Posts\Composers;
use Illuminate\Foundation\Composer;
use Komma\Posts\PostService;
class LatestPostsComposer
{
private $postService;
public function __construct(PostService $postService)
{
$this->postService = $postService;
}
public function compose($view)
{
$posts = $this->postService->getLatestPosts(4);
if($view->getName() == 'composed.allPosts') $posts = $this->postService->getAllPosts();
$this->postService->makeCarbonDate($posts);
$view->with(['posts'=> $posts]);
}
}