json($archiveHistory); } public function move(Request $request) { $data = $request->validate([ 'issue_at' => 'nullable|numeric:', 'return_at' => 'nullable|numeric:', 'org_id' => 'required|numeric', 'employee_name' => 'nullable|string', 'employee_post' => 'nullable|string', 'comment' => 'nullable|string', 'has_lost' => 'boolean', 'historyable_id' => 'nullable|numeric', ]); // Находим связанную модель ?? $historyable = SttMedicalHistory::findOrFail($data['historyable_id']); // Преобразуем timestamp в дату, если пришли числа if (isset($data['issue_at']) && is_numeric($data['issue_at'])) { $data['issue_at'] = Carbon::createFromTimestampMs($data['issue_at'])->format('Y-m-d'); } if (isset($data['return_at']) && is_numeric($data['return_at'])) { $data['return_at'] = Carbon::createFromTimestampMs($data['return_at'])->format('Y-m-d'); } $archiveHistory = ArchiveHistory::create($data); return response()->json(ArchiveHistoryResource::make($archiveHistory)); } }