Home > Back-end >  get the record form db against array in laravel
get the record form db against array in laravel

Time:06-22

$c array include room numbers. how to get all record in a room_number coulmn except room numbers in the array

  $available = array();
foreach ($c as $value) {

    $arooms = DB::table('tbl_rooms')->where('room_number', '<>' , $value)->first();


    array_push($available , $arooms);
  }

return response()->json(['data'=>$available]);

CodePudding user response:

Its really simple you can do this.

DB::table('tbl_rooms')->whereNotIn('room_number', $c)->get();
  • Related