|
|
|
|
@ -9,6 +9,7 @@
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
use App\Models\Orders;
|
|
|
|
|
use App\Models\Project;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class OrdersController extends CommonController
|
|
|
|
|
@ -20,6 +21,22 @@ class OrdersController extends CommonController
|
|
|
|
|
|
|
|
|
|
public function index(Request $request)
|
|
|
|
|
{
|
|
|
|
|
$projects = (new StatisticsController())->_checkProjects();
|
|
|
|
|
if (!$projects->count()) {
|
|
|
|
|
return $this->error($this->noProjects);
|
|
|
|
|
}
|
|
|
|
|
$project_id = request()->project_id ?? $projects->first()->id;
|
|
|
|
|
$project = Project::find($project_id);
|
|
|
|
|
|
|
|
|
|
$month = request()->month ?? date("Y-m");
|
|
|
|
|
$months = (new StatisticsController())->_getMonths();
|
|
|
|
|
|
|
|
|
|
$start_timestamp = strtotime($month);
|
|
|
|
|
$end_timestamp = strtotime("+1 month", strtotime($month));
|
|
|
|
|
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
|
|
$data = $this->model
|
|
|
|
|
->with([
|
|
|
|
|
"orderItems",
|
|
|
|
|
@ -29,8 +46,8 @@ class OrdersController extends CommonController
|
|
|
|
|
"product",
|
|
|
|
|
"customer",
|
|
|
|
|
"manager",
|
|
|
|
|
"bed" => function($query) {
|
|
|
|
|
$query->with(["room","building"]);
|
|
|
|
|
"bed" => function ($query) {
|
|
|
|
|
$query->with(["room", "building"]);
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
->orderBy("id", "desc")
|
|
|
|
|
@ -39,6 +56,6 @@ class OrdersController extends CommonController
|
|
|
|
|
$order = $order->refreshTotal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return view($this->bladePath . ".index", compact("data"));
|
|
|
|
|
return view($this->bladePath . ".index", compact("data", "project_id", "month", "project"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|