Select query for retrieve checkbox data in laravel

3108 views php

Greeting developers, I am new to laravel.I try to create checkbox form and try to retrieve data from it. It works for me but is there any easiest method there to do checkbox selection query. I think may be can use array to fetch the particular word but i dont know how the syntax will been in laravel. Below i attach the code thank in advance.


  public function show()
       $users = DB::table('notification')->whereIn('to', ['member','Merchant,member', 'Affliate,Merchant,member','Affliate,member'])->get();

        return view('usernotify',['users'=>$users]); 


<div class="tab"><div class="td">
  <label >Notification:  </label><br>
  <label>Content:</label>&nbsp&nbsp<input type="text" name="content" placeholder="content" >
   <label>To:</label><br><input type="checkbox" name="to[]" value="Affliate">Affiliate<br>
   <input type="checkbox" name="to[]" value="Merchant">Merchant<br>
   <input type="checkbox" name="to[]" value="member">Member<br>
   <input type="submit" value="submit"></div></div>

answered question

1 Answer


$users = DB::table('notification')->where('to', 'like', '%member%')->get();

posted this

Have an answer?


Please login first before posting an answer.