Fixed some things with the test add functions
This commit is contained in:
parent
6079524c4e
commit
de8e523c2c
@ -14,7 +14,7 @@ final class AddTestsTable extends AbstractMigration {
|
|||||||
->addTimestamps()
|
->addTimestamps()
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
$table = $this->table('tests_benchmarks');
|
$table = $this->table('test_benchmark');
|
||||||
$table->addColumn('test_id', 'integer', ['null' => false])
|
$table->addColumn('test_id', 'integer', ['null' => false])
|
||||||
->addColumn('benchmark_id', 'integer', ['null' => false])
|
->addColumn('benchmark_id', 'integer', ['null' => false])
|
||||||
->addForeignKey('test_id', 'tests', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
->addForeignKey('test_id', 'tests', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
||||||
|
@ -49,13 +49,13 @@ class TestController extends Controller {
|
|||||||
$test->description = $params['test_description'];
|
$test->description = $params['test_description'];
|
||||||
$test->component_id = $params['test_component'];
|
$test->component_id = $params['test_component'];
|
||||||
|
|
||||||
|
$test->save();
|
||||||
|
|
||||||
// attach benchmarks to test
|
// attach benchmarks to test
|
||||||
foreach ($params['test_benchmarks'] as $b) {
|
foreach ($params['test_benchmarks'] as $b) {
|
||||||
$test->benchmarks()->attach($b);
|
$test->benchmarks()->attach($b);
|
||||||
}
|
}
|
||||||
|
|
||||||
$test->save();
|
|
||||||
|
|
||||||
// redirect the user back to the home page
|
// redirect the user back to the home page
|
||||||
$routeContext = RouteContext::fromRequest($request);
|
$routeContext = RouteContext::fromRequest($request);
|
||||||
$routeParser = $routeContext->getRouteParser();
|
$routeParser = $routeContext->getRouteParser();
|
||||||
|
@ -16,7 +16,7 @@ class Test extends Model {
|
|||||||
return $this->hasMany(Result::class);
|
return $this->hasMany(Result::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function benchmark() {
|
public function benchmarks() {
|
||||||
return $this->belongsToMany(Benchmark::class);
|
return $this->belongsToMany(Benchmark::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
<div class="twelve columns">
|
<div class="twelve columns">
|
||||||
<label>
|
<label>
|
||||||
Benchmarks:
|
Benchmarks:
|
||||||
<select id="benchmark-selector" class="u-full-width" name="test_benchmarks" multiple>
|
<select id="benchmark-selector" class="u-full-width" name="test_benchmarks[]" multiple>
|
||||||
{% for b in benchmarks %}
|
{% for b in benchmarks %}
|
||||||
<option value="{{ b.id }}">{{ b.name }}</option>
|
<option value="{{ b.id }}">{{ b.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user