Laravel 5 simple search box using GET method
First of all, I know there are many ways to do this, and this might not be the best way to do it.
So what we are going to do is to add a search box text field in the upper left side of our table. Definitely it will search for any records containing the word to search. The search box can be reuse in other index as well to make tidy codes.
First Step: View
This is the search box (please never mind the add link, you can remove it if you want). Here, we create a form that will direct to officesController@index. The method we use is GET. The role is the variable you will use in your URI to put the search parameter.
{!! Form::open(['method'=>'GET','url'=>'offices','class'=>'navbar-form navbar-left','role'=>'search']) !!}
<a href="{{ url('offices/create') }}" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-plus"></span> Add</a>
<div class="input-group custom-search-form">
<input type="text" class="form-control" name="search" placeholder="Search...">
<span class="input-group-btn">
<button class="btn btn-default-sm" type="submit">
<i class="fa fa-search"><!--<span class="hiddenGrammarError" pre="" data-mce-bogus="1"-->i>
</button>
</span>
</div>
{!! Form::close() !!}
{!! Form::open(['method'=>'GET','url'=>'offices','class'=>'navbar-form navbar-left','role'=>'search']) !!}
<a href="{{ url('offices/create') }}" class="btn btn-primary btn-sm"><span class="glyphicon
Link:
This post is submitted by our members. Submit a new post.
Tags: Tutorials Laravel 5 Laravel 5.1