diff --git a/db/migrations/20230923020649_add_tests_table.php b/db/migrations/20230923020649_add_tests_table.php index 31ee7d9..5206cb2 100644 --- a/db/migrations/20230923020649_add_tests_table.php +++ b/db/migrations/20230923020649_add_tests_table.php @@ -14,7 +14,7 @@ final class AddTestsTable extends AbstractMigration { ->addTimestamps() ->create(); - $table = $this->table('tests_benchmarks'); + $table = $this->table('test_benchmark'); $table->addColumn('test_id', 'integer', ['null' => false]) ->addColumn('benchmark_id', 'integer', ['null' => false]) ->addForeignKey('test_id', 'tests', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE']) diff --git a/src/Controllers/TestController.php b/src/Controllers/TestController.php index 589df69..5ad7a67 100644 --- a/src/Controllers/TestController.php +++ b/src/Controllers/TestController.php @@ -49,13 +49,13 @@ class TestController extends Controller { $test->description = $params['test_description']; $test->component_id = $params['test_component']; + $test->save(); + // attach benchmarks to test foreach ($params['test_benchmarks'] as $b) { $test->benchmarks()->attach($b); } - $test->save(); - // redirect the user back to the home page $routeContext = RouteContext::fromRequest($request); $routeParser = $routeContext->getRouteParser(); diff --git a/src/Models/Test.php b/src/Models/Test.php index f862a7c..493db8d 100644 --- a/src/Models/Test.php +++ b/src/Models/Test.php @@ -16,7 +16,7 @@ class Test extends Model { return $this->hasMany(Result::class); } - public function benchmark() { + public function benchmarks() { return $this->belongsToMany(Benchmark::class); } diff --git a/views/test/add.twig b/views/test/add.twig index d17d3b3..e8cb174 100644 --- a/views/test/add.twig +++ b/views/test/add.twig @@ -37,7 +37,7 @@