|
|
|
|
@ -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");
|
|
|
|
|
|