2017-02-02 51 views
0

我有这个网址:如何从网址获取参数并查看?

http://test.dev/search?publishing_types[]=Selling&priceFrom=0&priceTo=300000&areaFrom=0&areaTo=300000&floors[]=2&yearFrom=1900&yearTo=2017 

现在我想考虑的是这样的:

<input type="checkbox" class="preventUncheck" name="publishing_types[]" id="toggle-on{{ $index }}" value="{{ $prop_type }}" @if (publishg_types== Selling) {!! "checked" !!} @endif > 

    <input type="checkbox" class="preventUncheck" name="publishing_types[]" id="toggle-on{{ $index }}" value="{{ $prop_type }}" @if (publishg_types== Reng) {!! "checked" !!} @endif > 

所以我想是从URL如果publishing_types == Selling和/或publishing_types == Rent在复选框检查检查复选框

+0

如果你把它传递给你的方法,你可以简单地使用'$ request ['NAME']'否则你必须通过它 – DestinatioN

+0

在我看来这个错误,然后未定义的变量:请求 – uzhas

+0

使用'request()'-helper函数与'request('publishing_types')' – Sebastian

回答

0

使用request()助手这样的:

<input type="checkbox" class="preventUncheck" name="publishing_types[]" id="toggle-on{{ $index }}" value="{{ $prop_type }}" @if (in_array('Selling', request(publishg_types)) {!! "checked" !!} @endif > 

<input type="checkbox" class="preventUncheck" name="publishing_types[]" id="toggle-on{{ $index }}" value="{{ $prop_type }}" @if (in_array('Reng', request(publishg_types)) {!! "checked" !!} @endif >