9 months ago

how to search data from more then one field in laravel

Posted 9 months ago by tanveerkhanwd

my view:

        <div class="box-body">
          {{ csrf_field() }}
          <!-- text input -->
          <div class="form-group">
            <div class="col-sm-3">
              {!! Form::text('search','',['class'=>'form-control','placeholder'=>'Search','required'=>'required']); !!}
              <span class="text-danger">{{ $errors->first('search') }}</span>
            <div class="col-sm-2">
              {!! Form::submit('search',['class'=>'btn btn-primary']); !!}
              <span class="text-danger">{{ $errors->first('status') }}</span>
      {!! Form::close() !!} 

My Controller:

public function index(Request $request)
        $search = \Request::get('search');
        $records = config('constant.displayPageRecords');
        $admission = Admission::where('name','like','%'.$search.'%')
        return view('admin.admission.index',['admission'=>$admission,'records'=>$records]);

Please sign in or create an account to participate in this conversation.