Реализация смены статуса
Добавлен move метод Правка в поиске
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\ArchiveHistoryResource;
|
||||
use App\Models\ArchiveHistory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class ArchiveHistoryController extends Controller
|
||||
{
|
||||
@@ -18,4 +20,34 @@ class ArchiveHistoryController extends Controller
|
||||
|
||||
return response()->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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\ArchiveHistoryResource;
|
||||
use App\Http\Resources\ArchiveInfoResource;
|
||||
use App\Models\SI\SttMedicalHistory;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -19,6 +20,10 @@ class MedicalHistoryController extends Controller
|
||||
$archiveJournal = ArchiveHistoryResource::collection($patient->archiveHistory);
|
||||
$archiveInfo = $patient->archiveInfo;
|
||||
|
||||
if (!empty($archiveInfo)) {
|
||||
$archiveInfo = ArchiveInfoResource::make($patient->archiveInfo);
|
||||
}
|
||||
|
||||
$patientInfo = [
|
||||
'info' => $patient,
|
||||
'journal' => $archiveJournal,
|
||||
|
||||
Reference in New Issue
Block a user