Laravel if input equals to zero write placeholder

- 1 answer

Ad

I'm trying to write this line of code in blade laravel so that if Input::get('query', '') equals to zero writes 'Document name' (placeholder) else it writes in value Input::get('query', '').

 <input name="query"  type="search"  value="{!! Input::get('query', '') !!}" placeholder="Document name" id="inputSearch">

I tried:

<input name="query"  type="search"  value="@if (Input::get('query', '') != 0) {!! Input::get('query', '') !!} @endif" placeholder="Document name" id="inputSearch">

Help pls?

Ad

Answer

Ad

Use this

value= "{{(Input::get('query')) ? (Input::get('query')) : ""}}"
Ad
source: stackoverflow.com
Ad