How to check is form was submitted?
view:
{!! Form::open(['method' => 'GET', 'action' => 'JobController@index']) !!}
<div class="form-group">
{!! Form::label('keywords','Keywords' ) !!}
{!! Form::text('keywords', null, array('class' => 'form-control')) !!}
</div>
{!! Form::submit('submit', array('class' => 'btn btn-primary form-control ')) !!}
{!! Form::close() !!}
Controller:
public function index(Request $request) {
// if(!empty($request->keywords)) {
//
// $search = Post::where("keywords","LIKE","%{$request->keywords}%")
// ->paginate(10);
// }
if(!empty($request->submit)) {
$search = Post::where("keywords","LIKE","%{$request->keywords}%")
->paginate(10);
}
}
$request->keywords is working fine. $request->submit shows nothing. Is this constuction do not work in Laravel? Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire