2014-09-04 19 views
4

我使用Laravel 4如何檢查是否Laravel請求沒有輸入

我願意來顯示文本,只有當我的請求不包含input

舉例來說,我有一個產品列表mysite/products我有一個輸入字段的價格,這給下面的網址,一旦點擊過濾:mysite/products?price=true

我可以用if(Input::has('price'))檢查,如果我有這樣的投入,但事情是,我有一大堆的輸入字段,並我只想在沒有輸入時顯示文字。

我的想法是這樣的:

@if(Input::has('price')||Input::has('mixed')||Input::has('male')||Input::has('female')||Input::has('kid')||Input::has('page')) 
    //Do nothing 
@else 
    //Display my text here 
@endif 

但簡化的方式...

我想檢查與Request::segment(1) URI的和看它是否符合'products',但它甚至不輸入有效。

回答

10

獲取所有輸入數據,又算什麼呢:

@if (! count(Input::all())) 
    // Display text here 
@endif 
+0

謝謝,就像一個魅力! – PhilMarc 2014-09-04 00:37:34