Modified some views, routes and models to work with the new many-to-many for tests and benchmarks
This commit is contained in:
@ -47,9 +47,13 @@ class TestController extends Controller {
|
||||
$test = new Test;
|
||||
$test->title = $params['test_title'];
|
||||
$test->description = $params['test_description'];
|
||||
$test->benchmark_id = $params['test_benchmark'];
|
||||
$test->component_id = $params['test_component'];
|
||||
|
||||
// attach benchmarks to test
|
||||
foreach ($params['test_benchmarks'] as $b) {
|
||||
$test->benchmarks()->attach($b);
|
||||
}
|
||||
|
||||
$test->save();
|
||||
|
||||
// redirect the user back to the home page
|
||||
|
@ -13,7 +13,7 @@ class Benchmark extends Model {
|
||||
];
|
||||
|
||||
public function tests() {
|
||||
return $this->hasMany(Test::class);
|
||||
return $this->belongsToMany(Test::class);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,11 @@ class Test extends Model {
|
||||
}
|
||||
|
||||
public function benchmark() {
|
||||
return $this->belongsTo(Benchmark::class);
|
||||
return $this->belongsToMany(Benchmark::class);
|
||||
}
|
||||
|
||||
public function component() {
|
||||
return $this->belongsTo(Component::class);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user