adhik13th
5 months ago
533
9
Laravel

Select Multiple value getting error on where clause

Posted 5 months ago by adhik13th

I have a Input select 2 , and its want multiple value so this data is array . its my input :

      <form action="{{ route('search_filter') }}" method="GET">
                                <div class="select is-multiple is-focused">
                                    <select name="gejala[]" multiple size="5">
                                      <option value='demam'>demam</option>
                                      <option value="riwayat_demam">riwayat_demam</option>
                                      <option value="batuk">batuk</option>
                                      <option value="pilek">pilek</option>
                                     </select>
                                <div>
      </form>

and this die dump on this input is :

array:3 [▼ 0 => "riwayat_demam" 1 => "batuk" 2 => "pilek" ]

sooo on my controller i create a function :

 public function search_filter(Request $request)
{   
    $input = $request->gejala;
   
    $stats = collect($input);

    $gejala = Gejala::where($stats , 'Ya')->paginate();
   
     dd($gejala);

    //return view('users.data_pasien',['gejala' => $gejala]);
}

but after submitting form i have error like this :

Column not found: 1054 Unknown column '["demam","riwayat_demam","batuk","pilek"]' in 'where clause' (SQL: select count(*) as aggregate from gejala where ["demam","riwayat_demam","batuk","pilek"] = Ya)

i use where , if i use whereIn this error like this :

Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, string given, called in

i think i missed on my query where clause multiple colomn in 1 value , can someone corect my code ?

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