amdp3-metaforums/Application/Controllers/IndexController.php

32 lines
922 B
PHP
Raw Normal View History

2019-11-18 13:33:45 +00:00
<?php
namespace Application\Controllers;
use Application\HTTP\Request;
use Application\HTTP\Response;
use Application\Services\ServiceContainer;
2019-11-19 03:36:39 +00:00
use Application\Models\Category;
use Application\Models\Group;
use Application\Models\Thread;
2019-11-18 13:33:45 +00:00
class IndexController {
public function __construct() {
}
public function index(Request $request, Response $response) {
2019-11-19 03:36:39 +00:00
$groups = Group::all();
$group = null;
$category = null;
$thread = null;
if(isset($request->group)) {
$group = Group::find($request->group);
}
if(isset($request->category)) {
$category = Category::find($request->category);
}
if(isset($request->thread)) {
$thread = Thread::find($request->thread);
}
return $response->view('index', ['groups' => $groups, 'group' => $group, 'category' => $category, 'thread' => $thread ] );
2019-11-18 13:33:45 +00:00
}
}