我有三种型号:
意甲($ id)
public function saisons()
{
return $this->hasMany(Season::class);
}
public function episodes()
{
return $this->hasManyThrough(Episode::class, Season::class);
}
季节($ serie_id)
public function serie()
{
return $this->belongsTo(Serie::class);
}
public function episodes()
{
return $this->hasMany(Episode::class);
}
集锦($ season_id)
public function season()
{
return $this->belongsTo(Season::class);
}
public function serie()
{
return $this->BelongsToThrough(Serie::class, Season::class);
}
我想在意甲中展示一个特定的赛季,并将其与相关的事件相关联
我的观点
<h1 class="title">{{$serie->seasons->number}}</h1>
@foreach ($serie->seasons->episodes as $episode)
<div class="row">
<div class="columns">
<div class="col">
{{$episode->number}}
<a href="{{route('episodes.show', $episode->id)}}">{{$episode->name}}</a>
@if(isset($episode->programmation->date))
{{$episode->programmation->date}}
@endif
@if (($episode->season_finale) == '0')
Non
@elseif (($episode->season_finale) == '1')
Oui
@endif
@foreach ($episode->chaines as $chaine)
{{$chaine->name}}
@endforeach
</div>
</div>
</div>
@endforeach
路线
Route::get('/serie/{serie}/saison/{season}', 'Front\SaisonController@show')->name('saison.show');
对于我的网址,我选择显示病房号而不是ID,我认为这就是问题所在。
我该如何以正确的方式做到这一点?
答案 0 :(得分:0)
我认为这种方法可以为您提供帮助。
$serie = Serie::where('id',$id)->with('seasons'=>function($query) use ($season_id) {
$query->where('season_id',$season_id)->with('episodes')->get();
})->get();
答案 1 :(得分:0)
好吧,有人帮助我找到正确的答案:
SELECT t1.day, t1.speed, t1.nor
FROM (SELECT id, day, ABS(report.speed) AS speed, nor
FROM report
WHERE report.name = 'SYN'
AND report.day > '2016-01-01 00:00:00'
AND report.speed BETWEEN -40 AND -0.0001) AS t1,
(SELECT AVG(ABS(speed)) + 3 * STD(ABS(speed)) AS value
FROM report
WHERE report.name = 'SYN'
AND report.day > '2016-01-01 00:00:00'
AND report.speed BETWEEN -40 AND -0.0001) AS t2
WHERE t1.speed < t2.value
AND t1.nor < t2.value;