update
This commit is contained in:
@@ -217,6 +217,44 @@ class BiorepositoryController extends Controller
|
||||
return redirect('/biorepository')->with('success', 'Spesimen berhasil dihapus.');
|
||||
}
|
||||
|
||||
public function deleteRack($id)
|
||||
{
|
||||
if (Session::get('previlage') == '') {
|
||||
return redirect('/login');
|
||||
}
|
||||
|
||||
$rack = BioRack::find($id);
|
||||
if (!$rack) {
|
||||
return redirect('/biorepository')->withErrors(['rack' => 'Data rack tidak ditemukan.']);
|
||||
}
|
||||
|
||||
BioSpecimen::where('rack_id', $rack->id)->delete();
|
||||
$rack->delete();
|
||||
|
||||
return redirect('/biorepository')->with('success', 'Rack dan semua spesimennya berhasil dihapus.');
|
||||
}
|
||||
|
||||
public function deleteCabinet($id)
|
||||
{
|
||||
if (Session::get('previlage') == '') {
|
||||
return redirect('/login');
|
||||
}
|
||||
|
||||
$cabinet = BioCabinet::find($id);
|
||||
if (!$cabinet) {
|
||||
return redirect('/biorepository')->withErrors(['cabinet' => 'Data lemari tidak ditemukan.']);
|
||||
}
|
||||
|
||||
$rackIds = BioRack::where('cabinet_id', $cabinet->id)->pluck('id')->toArray();
|
||||
if (!empty($rackIds)) {
|
||||
BioSpecimen::whereIn('rack_id', $rackIds)->delete();
|
||||
BioRack::whereIn('id', $rackIds)->delete();
|
||||
}
|
||||
$cabinet->delete();
|
||||
|
||||
return redirect('/biorepository')->with('success', 'Lemari beserta rack dan spesimennya berhasil dihapus.');
|
||||
}
|
||||
|
||||
private function mapStorageCondition($category)
|
||||
{
|
||||
$mapping = [
|
||||
|
||||
Reference in New Issue
Block a user