File: D:/HostingSpaces/Neopoints/momsecurity.be/app/Komma/Employees/EmployeeController.php
<?php
namespace App\Komma\Employees;
use App\Http\Controllers\Controller;
use App\Komma\Employees\Models\Employee;
class EmployeeController extends Controller
{
private $pagePrefix = 'employees:';
private $employeeService;
public function __construct(EmployeeService $employeeService)
{
parent::__construct();
$this->employeeService = $employeeService;
}
/**
* @return \Illuminate\Contracts\View\View
*/
public function index()
{
$page = $this->pageService->getPageByCodeName('employees');
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
$employees = $this->employeeService->getAllEmployees(true, 3);
$employees->withPath('/' . $this->links->employees->route);
// Fetch and prepare components
if($components = $page->translation->componentAreaComponents)
{
$components = $this->componentService->prepare($components);
}
// Return view
return \View::make($this->baseViewPath.$this->pagePrefix.'index',[
'page' => $page,
'links' => $this->links,
'otherLanguages' => $otherLanguageRoutes,
'employees' => $employees,
'components' => $components,
]);
}
/**
* @return \Illuminate\Contracts\View\View
*/
public function filters()
{
$filters = request('filters');
dd('customize filter function in EmployeeController');
// if (sizeof($filters) != 1) {
// throw abort(404);
// }
// $categoryName = $filters[0];
//
// // Check if category exist else trow 404
// if ( ! $category = EmployeeCategoryTranslation::where('slug', $categoryName)
// ->with('translatable')
// ->first()) {
// throw abort(404);
// }
//
// $page = $this->pageService->getPageByCodeName('blog');
// $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
//
// //Get employees through the category
// $employees = $category->translatable->employees()->paginate(8);
// $employees->withPath('/' . $this->links->blog->route . '/' . $category->slug);
//
//
// // Return view
// return \View::make($this->baseViewPath.$this->pagePrefix.'index',[
// 'page' => $page,
// 'links' => $this->links,
// 'otherLanguages' => $otherLanguageRoutes,
// 'employees' => $employees,
// ]);
}
/**
* @param Employee $employee
* @return \Illuminate\Contracts\View\View
*/
public function show(Employee $employee)
{
$employee->load('translation','translations');
$page = $this->pageService->getPageByCodeName('employees');
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page, $employee);
// Return view
return \View::make($this->baseViewPath.$this->pagePrefix.'show',[
'page' => $page,
'employee' => $employee,
'links' => $this->links,
'otherLanguages' => $otherLanguageRoutes
]);
}
}