File: D:/HostingSpaces/SBogers10/anvil.komma.pro/app/KommaApp/Posts/PostController.php
<?php
namespace App\KommaApp\Posts;
use App\Http\Controllers\Controller;
use App\KommaApp\Posts\Models\Post;
class PostController extends Controller
{
private $pagePrefix = 'pages.posts.';
private $postService;
public function __construct(PostService $postService)
{
parent::__construct();
$this->postService = $postService;
}
/**
* @return \Illuminate\Contracts\View\View
*/
public function index()
{
$page = $this->pageService->getPageByCodeName('posts');
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
$posts = $this->postService->getAllPosts(true);
// Return view
return \View::make($this->baseViewPath.$this->pagePrefix.'index', [
'page' => $page,
'links' => $this->links,
'otherLanguages' => $otherLanguageRoutes,
'posts' => $posts,
]);
}
/**
* @return \Illuminate\Contracts\View\View
*/
public function filters()
{
$filters = request('filters');
var_dump('Filter posts with these filters:');
dd($filters);
$page = $this->pageService->getPageByCodeName('posts');
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
$posts = $this->postService->getAllPosts(true);
// Return view
return \View::make($this->baseViewPath.$this->pagePrefix.'index', [
'page' => $page,
'links' => $this->links,
'otherLanguages' => $otherLanguageRoutes,
'posts' => $posts,
]);
}
/**
* @param Page $page
* @return \Illuminate\Contracts\View\View
*/
public function show(Post $post)
{
$post->load('translation', 'sites');
// This checks if the post belongs to the set site
if (! $post->sites->contains(\App::getSite())) {
throw abort(404);
}
$page = $this->pageService->getPageByCodeName('posts');
$page->translation = $this->decodeDynamicContent($page->translation);
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page, $post);
// Return view
return \View::make($this->baseViewPath.$this->pagePrefix.'show', [
'page' => $page,
'post' => $post,
'links' => $this->links,
'otherLanguages' => $otherLanguageRoutes,
]);
}
}