Advertisement
Kurczakovsky

Untitled

Jul 7th, 2022
815
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         $investment = $this->repository->find(1);
  2.         $investment_room = $investment->load(array(
  3.             'floorRooms' => function ($query) use ($request) {
  4.                 if ($request->input('rooms')) {
  5.                     $query->where('rooms', $request->input('rooms'));
  6.                 }
  7.                 if ($request->input('status')) {
  8.                     $query->where('status', $request->input('status'));
  9.                 }
  10.                 if ($request->input('area')) {
  11.                     $area_param = explode('-', $request->input('area'));
  12.                     $min = $area_param[0];
  13.                     $max = $area_param[1];
  14.                     $query->whereBetween('area', [$min, $max]);
  15.                 }
  16.                 if ($request->input('sort')) {
  17.                     $order_param = explode(':', $request->input('sort'));
  18.                     $column = $order_param[0];
  19.                     $direction = $order_param[1];
  20.                     $query->orderBy($column, $direction);
  21.                 }
  22.             }
  23.         ));
Advertisement
RAW Paste Data Copied
Advertisement