I need to make search form in Laravel
This is code welcome.blade.php:
<form action="/search" method="POST" role="search">
{{ csrf_field() }}
<div class="input-group">
<input type="text" class="form-control" name="q"
placeholder="Search job"> <span class="input-group-btn">
<button type="submit" class="btn btn-default">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
<div class="container">
@if(isset($details))
<div class="row">
@foreach( $details as $job)
<h5>{{$job->company_name}}</h5>
<h3>{{$job->job_name}}</h3>
@endforeach
</div>
@endif
</div>
This is route in web.php:
Route::any('/search', function () {
$q = Input::get('q');
$job = Job::where('job_name', 'LIKE', '%' . $q . '%')
->orWhere('company_name', 'LIKE', '%' . $q . '%')
->get();
if (count($job) > 0)
return view('welcome')
->withDetails($job)
->withQuery($q);
else
return view('welcome')
->withMessage('No Details found. Try to search again !');
});
I am getting an error:
Call to undefined method Symfony\Component\Console\Input\Input::get()
How I can fix it?
Also I would like to know, how could I first display all jobs, and after search only jobs that match?