Php 如何使用Laravel连接到路由的末尾?

Php 如何使用Laravel连接到路由的末尾?,php,laravel,routes,blade,Php,Laravel,Routes,Blade,我正在使用Laravel创建一个项目 在标记中使用{{route('routename')}}有没有连接到url末尾的方法 我创建了一个缩略图列表,使用foreach循环链接到完整大小的图像集合 @foreach ($images as $image) <a href="{{ route('images') }}"> // link to full size image collection <img src="{{ $image->url }}"

我正在使用Laravel创建一个项目

标记中使用
{{route('routename')}}
有没有连接到url末尾的方法

我创建了一个缩略图列表,使用foreach循环链接到完整大小的图像集合

@foreach ($images as $image)
    <a href="{{ route('images') }}"> // link to full size image collection
        <img src="{{ $image->url }}">// thumbnail image
    </a>
@endforeach

有人知道方法吗?

我能够通过使用此代码来实现这一点

<?php $n = 1; ?>
@foreach ($images as $image)
    <a href="{{ route('images') . '?page=' . $n }}"> // link to full size image collection
        <img src="{{ $image->url }}">// thumbnail image
    </a>
    <?php $n++; ?>
@endforeach

@foreach($images作为$image)
@endforeach

您自己发现的方法工作得非常好,但还有一种更优雅的方法。作为第二个参数传递的所有参数(如
{page}
)都将作为查询字符串追加

{{ route('images', ['page' => $n]) }}

这取决于您的数组/集合,但您可能需要执行
@foreach($n=>$image)
,然后执行
“?page=”$n+1
,这样您就可以去掉
$n=1
$n++
行了
{{ route('images', ['page' => $n]) }}