feat: 第二阶段核心业务模块(CRM/房务/护理/月子餐)
后端: - 4个迁移文件新增23张业务表 - 23个Eloquent Model(含关联/类型转换/门店隔离) - 20个Controller(含CRUD+业务操作: 合同审核/入住退房/护理异常处理等) - 110+条API路由(crm/room/care/meal四大前缀) 前端: - 4个API模块(crm.js/room.js/care.js/meal.js) - 13个业务页面(线索/客户/合同/渠道/投诉/房型/房间/预定/护理档案/护理计划/护理记录/菜品/排餐)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Care;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Care\HealthMetric;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HealthMetricController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = HealthMetric::query()->with('recorder');
|
||||
$query->when($request->care_profile_id, fn($q, $v) => $q->where('care_profile_id', $v));
|
||||
$query->when($request->metric_type, fn($q, $v) => $q->where('metric_type', $v));
|
||||
$query->when($request->start_date, fn($q, $v) => $q->where('recorded_at', '>=', $v));
|
||||
$query->when($request->end_date, fn($q, $v) => $q->where('recorded_at', '<=', $v));
|
||||
|
||||
return $this->paginate($query->latest('recorded_at')->paginate($request->input('per_page', 50)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'care_profile_id' => 'required|exists:care_profiles,id',
|
||||
'metric_type' => 'required|string|max:30',
|
||||
'value' => 'required|numeric',
|
||||
'unit' => 'nullable|string|max:10',
|
||||
'recorded_at' => 'sometimes|date',
|
||||
'remark' => 'nullable|string|max:255',
|
||||
]);
|
||||
$validated['recorder_id'] = auth()->id();
|
||||
$validated['recorded_at'] = $validated['recorded_at'] ?? now();
|
||||
|
||||
return $this->success(HealthMetric::create($validated));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user