update
This commit is contained in:
@@ -30,7 +30,7 @@ class BiorepositoryController extends Controller
|
||||
|
||||
$data['cabinets'] = BioCabinet::with([
|
||||
'racks' => function ($query) {
|
||||
$query->orderBy('level', 'ASC')->orderBy('rack_number', 'ASC');
|
||||
$query->orderBy('rack_number', 'ASC')->orderBy('code', 'ASC');
|
||||
},
|
||||
'racks.specimens' => function ($query) {
|
||||
$query->orderBy('stored_at', 'ASC');
|
||||
@@ -79,10 +79,8 @@ class BiorepositoryController extends Controller
|
||||
'cabinet_id' => 'required|exists:bio_cabinets,id',
|
||||
'code' => 'required|max:50',
|
||||
'name' => 'required|max:150',
|
||||
'level' => 'required|integer|min:1',
|
||||
'rack_number' => 'required|integer|min:1',
|
||||
'box_number' => 'required|integer|min:1',
|
||||
'capacity' => 'required|integer|min:1',
|
||||
'level' => 'required|integer|min:4|max:6',
|
||||
'capacity' => 'required|integer|min:16|max:20',
|
||||
'notes' => 'nullable',
|
||||
]);
|
||||
|
||||
@@ -98,13 +96,15 @@ class BiorepositoryController extends Controller
|
||||
return back()->withErrors(['code' => 'Kode rack sudah dipakai pada lemari ini.'])->withInput();
|
||||
}
|
||||
|
||||
$nextRackNumber = ((int) BioRack::where('cabinet_id', $request->input('cabinet_id'))->max('rack_number')) + 1;
|
||||
|
||||
BioRack::create([
|
||||
'cabinet_id' => $request->input('cabinet_id'),
|
||||
'code' => $request->input('code'),
|
||||
'name' => $request->input('name'),
|
||||
'level' => $request->input('level'),
|
||||
'rack_number' => $request->input('rack_number'),
|
||||
'box_number' => $request->input('box_number'),
|
||||
'rack_number' => $nextRackNumber,
|
||||
'box_number' => 1,
|
||||
'capacity' => $request->input('capacity'),
|
||||
'notes' => $request->input('notes'),
|
||||
]);
|
||||
@@ -135,22 +135,26 @@ class BiorepositoryController extends Controller
|
||||
$expectedRackNo = $rack->rack_number ?: $rack->id;
|
||||
$expectedBoxNo = $rack->box_number ?: 1;
|
||||
|
||||
if ((int) $request->input('shelfnomor') !== (int) $rack->level ||
|
||||
(int) $request->input('raknomor') !== (int) $expectedRackNo ||
|
||||
if ((int) $request->input('raknomor') !== (int) $expectedRackNo ||
|
||||
(int) $request->input('boxnomor') !== (int) $expectedBoxNo) {
|
||||
return back()->withErrors(['slotnomor' => 'Posisi slot tidak sesuai dengan konfigurasi rack.'])->withInput();
|
||||
}
|
||||
|
||||
if ((int) $request->input('slotnomor') > (int) $rack->capacity) {
|
||||
return back()->withErrors(['slotnomor' => 'Slot melebihi kapasitas rack.'])->withInput();
|
||||
if ((int) $request->input('shelfnomor') < 1 || (int) $request->input('shelfnomor') > (int) $rack->level) {
|
||||
return back()->withErrors(['shelfnomor' => 'Shelf melebihi konfigurasi rack.'])->withInput();
|
||||
}
|
||||
|
||||
if ((int) $request->input('tubenomor') < 1 || (int) $request->input('tubenomor') > (int) $rack->capacity) {
|
||||
return back()->withErrors(['tubenomor' => 'Nomor tube melebihi kapasitas box pada shelf ini.'])->withInput();
|
||||
}
|
||||
|
||||
$slotTaken = BioSpecimen::where('rack_id', $rack->id)
|
||||
->where('slot_number', $request->input('slotnomor'))
|
||||
->where('shelf_number', $request->input('shelfnomor'))
|
||||
->where('tube_number', $request->input('tubenomor'))
|
||||
->exists();
|
||||
|
||||
if ($slotTaken) {
|
||||
return back()->withErrors(['slotnomor' => 'Slot ini sudah terisi spesimen.'])->withInput();
|
||||
return back()->withErrors(['tubenomor' => 'Posisi tube pada shelf ini sudah terisi spesimen.'])->withInput();
|
||||
}
|
||||
|
||||
$atccByUser = strtoupper(preg_replace('/[^A-Za-z0-9]/', '', Session::get('nama', 'UNKNOWN')));
|
||||
@@ -182,7 +186,7 @@ class BiorepositoryController extends Controller
|
||||
'category_storage' => $request->input('kategorisimpan'),
|
||||
'shelf_number' => $request->input('shelfnomor'),
|
||||
'rack_number' => $request->input('raknomor'),
|
||||
'slot_number' => $request->input('slotnomor'),
|
||||
'slot_number' => $request->input('shelfnomor'),
|
||||
'box_number' => $request->input('boxnomor'),
|
||||
'tube_number' => $request->input('tubenomor'),
|
||||
'bacteria_name' => $request->input('nmbakteri'),
|
||||
|
||||
Reference in New Issue
Block a user