Re-worked test views and routes for new DB schema
This commit is contained in:
@ -6,6 +6,8 @@ use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Slim\Routing\RouteContext;
|
||||
use Slim\Views\Twig;
|
||||
use BitGoblin\Colossus\Models\Benchmark;
|
||||
use BitGoblin\Colossus\Models\Component;
|
||||
use BitGoblin\Colossus\Models\Test;
|
||||
|
||||
class TestController extends Controller {
|
||||
@ -29,16 +31,23 @@ class TestController extends Controller {
|
||||
}
|
||||
|
||||
public function getAdd(Request $request, Response $response): Response {
|
||||
$benchmarks = Benchmark::all();
|
||||
$components = Component::all();
|
||||
|
||||
$view = Twig::fromRequest($request);
|
||||
return $view->render($response, 'test/add.twig');
|
||||
return $view->render($response, 'test/add.twig', [
|
||||
'benchmarks' => $benchmarks,
|
||||
'components' => $components,
|
||||
]);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request, Response $response): Response {
|
||||
$params = (array)$request->getParsedBody();
|
||||
|
||||
$test = new Test;
|
||||
$test->name = $params['test_name'];
|
||||
$test->description = $params['test_description'];
|
||||
$test->date_tag = $params['test_date_tag'];
|
||||
$test->benchmark_id = $params['test_benchmark'];
|
||||
$test->component_id = $params['test_component'];
|
||||
|
||||
$test->save();
|
||||
|
||||
|
Reference in New Issue
Block a user