如何从网址获取参数并查看视图?

时间:2017-02-02 11:47:26

标签: laravel laravel-5 laravel-5.2

我有这个网址:

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 >

所以我想要的是检查来自网址的publishing_types == Selling和/或publishing_types == Rent复选框以检查该复选框

1 个答案:

答案 0 :(得分: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 >