File: D:/HostingSpaces/fire-tech/fire-tech.nl/app/KommaApp/Course/CourseController.php
<?php
namespace App\KommaApp\Courses;
use App\Http\Controllers\Controller;
use App\KommaApp\Courses\Models\Course;
class CourseController extends Controller
{
private $pagePrefix = 'pages.courses.';
private $courseService;
/**
* CourseController constructor.
* @param CourseService $serviceService
*/
public function __construct(CourseService $courseService)
{
parent::__construct();
$this->courseService = $courseService;
}
/**
* @return \Illuminate\Contracts\View\View
*/
public function index()
{
$page = $this->pageService->getPageByCodeName('courses');
$page->translation = $this->decodeDynamicContent($page->translation);
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
$courses = $this->courseService->getAllCourses();
//$courses->withPath('/' . $this->links->courses->route);
// Return view
return \View::make($this->baseViewPath . $this->pagePrefix . 'index', [
'page' => $page,
'links' => $this->links,
'otherLanguages' => $otherLanguageRoutes,
'courses' => $courses,
]);
}
/**
* @param Course $course
* @return \Illuminate\Contracts\View\View
*/
public function show(Course $course)
{
$course->load('translation');
$page = $this->pageService->getPageByCodeName('courses');
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page, $course);
// Load all Projects
$courses = $this->courseService->getAllCourses();
// Decode the dynamic content
$course->translation = $this->decodeDynamicContent($course->translation);
// Return view
return \View::make($this->baseViewPath . $this->pagePrefix . 'show', [
'page' => $page,
'course' => $course,
'links' => $this->links,
'courses' => $courses,
'otherLanguages' => $otherLanguageRoutes,
]);
}
}