我有$ win-> start,$ article-> from和$ article-> days
现在我想创建这样的HTML:
if ($article->from) > (Carbon::now()->addDays($article->days)) {
$r = Carbon::now()->addDays($article->days)
if ($r > $win->start) {
<div>get VOUCHER</div>
}
else {
<div>ACTIVE</div>
}
else {
$r = $article->from
if ($r > $win-> start) {
<div>get VOUCHER</div>
}
else {
<div>ACTIVE</div>
}
}
请帮助我用正确的刀片解决这个逻辑问题 - 碳代码...如何在刀片中创建两个?
答案 0 :(得分:1)
我认为这应该可以解决问题:
@foreach($wins as $win)
<div class="row">
<div class="col-md-4">
<p>{{ date('d M Y', strtotime($win->start)) }}</p>
</div>
<div class="col-md-4 text-right">
<p><strong>{{$win->price}} </strong>euros</p>
</div>
@if($article->from > \Carbon\Carbon::now()->addDays($article->days))
{{ $r = \Carbon\Carbon::now()->addDays($article->days) }}
@if($r > $win->start)
<div>get VOUCHER</div>
@else
<div>ACTIVE</div>
@endif
@else
{{ $r = $article->from }}
@if($r > $win-> start)
<div>get VOUCHER</div>
@else
<div>ACTIVE</div>
@endif
@endif
</div>
<hr style="margin:0px;">
@endforeach
更新:使用完整代码段