2 回答

TA貢獻1810條經驗 獲得超5個贊
public function index()
{
$proyects = Proyect::latest()->paginate(10);
return view('proyect.index', compact('proyects'));
}
array_chunk 是一個 php 函數,可以拼接你的數組。
@forelse(array_chunk($proyects->all(),2) as $rows)
<div class="row">
@foreach($rows as $proyect)
<div class="col-10 col-lg-12 col-md-6">
<div class="card-deck">
<div class="card">
<div class="card-body">
<h5 class="card-title">{{ $proyect->title }}</h5>
<h6 class="card-subtitle mb-2 text-muted">{{ $proyect->descripcion }}</h6>
<p class="card-text">You can use the cap image as overlay for the body</p>
<a href="{{ route('proyect.show', $proyect) }}" class="card-link">Ver mas</a>
</div>
<div class="card-footer">
<small class="text-muted">{{ $proyect->created_at->diffForHumans() }}</small>
</div>
</div>
</div>
</div>
@endforeach
</div>
@empty
<div>Empty ...</div>
@endforelse

TA貢獻1982條經驗 獲得超2個贊
可能這是您的解決方案:
<div class="row">
@forelse($proyects as $proyect)
<div class="col-6 col-lg-6 col-md-6">
<div class="card-deck">
<div class="card">
<div class="card-body">
<h5 class="card-title">{{ $proyect->title }}</h5>
<h6 class="card-subtitle mb-2 text-muted">
{{ $proyect->descripcion }}</h6>
<p class="card-text">You can use the cap image as an
overlay for the body</p>
<a href="{{ route('proyect.show', $proyect) }}"
class="card-link">Ver mas</a>
</div>
<div class="card-footer">
<small class="text-muted">
{{ $proyect->created_at->diffForHumans() }}</small>
</div>
</div>
@empty
<li> Empty </li>
</div>
@endforelse
</div>
- 2 回答
- 0 關注
- 218 瀏覽
添加回答
舉報