我想用按钮显示一个或多个JPG文件,我使用foreach
循环显示这些映像,但是当我有2个文件时,我目前会得到2个按钮。即使我有多个图像,我如何才能获得一个按钮。
@foreach($letter->documents AS $document)
@for($page = 1; $page <= $document->pages; $page++)
<input onclick="window.open('{{ '/send/'.$letter->id.'/documents/'.$document->id.'/'.$page.'/778x1008'}}')" value="View PDF example" type="button" class="left"></input>
@endfor
@endforeach
laravel循环具有继承的 $loop
变量,可以在这里找到哪个文档。
简而言之一个可以使用:
@foreach($letter->documents AS $document)
//Show image
@if ($loop->last)
//Create button
@endif
@endforeach