Commit 044d0ae6 authored by Georgios Tsakalos's avatar Georgios Tsakalos
Browse files

add labs in list all software action

parent ff6d949f
...@@ -114,7 +114,8 @@ return function (Slim\App $app) { ...@@ -114,7 +114,8 @@ return function (Slim\App $app) {
$container[Action\Software\ListAll::class] = function ($c) { $container[Action\Software\ListAll::class] = function ($c) {
return new Action\Software\ListAll( return new Action\Software\ListAll(
$c->get('view'), $c->get('view'),
$c->get(Service\SoftwareServiceInterface::class) $c->get(Service\SoftwareServiceInterface::class),
$c->get(Service\LabServiceInterface::class)
); );
}; };
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace GrEduLabs\Schools\Action\Software; namespace GrEduLabs\Schools\Action\Software;
use GrEduLabs\Schools\Service\SoftwareServiceInterface; use GrEduLabs\Schools\Service\SoftwareServiceInterface;
use GrEduLabs\Schools\Service\LabServiceInterface;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
use Slim\Views\Twig; use Slim\Views\Twig;
...@@ -20,10 +21,15 @@ class ListAll ...@@ -20,10 +21,15 @@ class ListAll
private $view; private $view;
private $softwareService; private $softwareService;
public function __construct(Twig $view, SoftwareServiceInterface $softwareService) public function __construct(
Twig $view,
SoftwareServiceInterface $softwareService,
LabServiceInterface $labservice
)
{ {
$this->view = $view; $this->view = $view;
$this->softwareService = $softwareService; $this->softwareService = $softwareService;
$this->labservice = $labservice;
} }
public function __invoke(Request $req, Response $res, array $args = []) public function __invoke(Request $req, Response $res, array $args = [])
...@@ -32,11 +38,13 @@ class ListAll ...@@ -32,11 +38,13 @@ class ListAll
if (!$school) { if (!$school) {
return $res->withStatus(403, 'No school'); return $res->withStatus(403, 'No school');
} }
$labs = $this->labservice->getLabsBySchoolId($school->id);
$software = $this->softwareService->getSoftwareBySchoolId($school->id); $software = $this->softwareService->getSoftwareBySchoolId($school->id);
$categories = $this->softwareService->getSoftwareCategories(); $categories = $this->softwareService->getSoftwareCategories();
return $this->view->render($res, 'schools/software.twig', [ return $this->view->render($res, 'schools/software.twig', [
'school' => $school, 'school' => $school,
'labs' => $labs,
'softwareArray' => $software, 'softwareArray' => $software,
'categories' => array_map(function ($category) { 'categories' => array_map(function ($category) {
return ['value' => $category['id'], 'label' => $category['name']]; return ['value' => $category['id'], 'label' => $category['name']];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment