diff --git a/app/Http/Controllers/Admin/OrdersController.php b/app/Http/Controllers/Admin/OrdersController.php index d8bd7a1..95c513e 100755 --- a/app/Http/Controllers/Admin/OrdersController.php +++ b/app/Http/Controllers/Admin/OrdersController.php @@ -43,11 +43,19 @@ class OrdersController extends CommonController $this->model = $this->model->whereRaw("UNIX_TIMESTAMP(`created_at`) >= " . $start_timestamp . " and UNIX_TIMESTAMP(`created_at`) < " . $end_timestamp); $this->model = $this->model->where("project_id", $project_id); + $user = auth()->user(); + $areaId = AdminAreaLink::where('project_id', $project_id)->where('admin_id', $user->id)->pluck('area_id'); + $bedList = Bed::whereIn('area_id',$areaId)->pluck('id'); + if ($request->keyword) { $this->model = $this->model->where(function ($query) use ($request) { $query->where("serial", "like", "%" . $request->keyword . "%") ->orWhere("contact", "like", "%" . $request->keyword . "%") ->orWhere("mobile", "like", "%" . $request->keyword . "%"); + })->where(function ($query) use ($bedList) { + if ($bedList) { + $query->whereIn('bed_id', $bedList); + } }); } @@ -67,7 +75,7 @@ class OrdersController extends CommonController "customer", "manager", "bed" => function ($query) { - $query->with(["room", "building"]); + $query->with(["room", "building","area"]); } ]) ->orderBy("id", "desc"); diff --git a/resources/views/admin/orders/index.blade.php b/resources/views/admin/orders/index.blade.php index f86dee6..29652cc 100755 --- a/resources/views/admin/orders/index.blade.php +++ b/resources/views/admin/orders/index.blade.php @@ -37,6 +37,8 @@