update logic for delete direction

This commit is contained in:
aslan 2024-03-13 15:40:26 +03:00
parent 04d596b0eb
commit f1ffe64ef3
1 changed files with 3 additions and 15 deletions

View File

@ -234,19 +234,9 @@ class DirectionController extends Controller
public function destroy(Direction $direction): RedirectResponse public function destroy(Direction $direction): RedirectResponse
{ {
if ($direction->entranceExaminations()->exists()) { $direction->entranceExaminations()->each(fn ($entranceExamination) => $entranceExamination->delete());
Log::channel('app') $direction->directionProfiles()->detach();
->error( $direction->delete();
'NOT DELETE напр. подготовки {direction} - user {user}',
[
'user' => Auth::user()->name,
'direction' => $direction->name,
'data' => $direction->toArray(),
]
);
return back();
}
Log::channel('app') Log::channel('app')
->critical( ->critical(
'DELETE напр. подготовки {direction} - user {user}', 'DELETE напр. подготовки {direction} - user {user}',
@ -256,8 +246,6 @@ class DirectionController extends Controller
'data' => $direction->toArray(), 'data' => $direction->toArray(),
] ]
); );
$direction->directionProfiles()->detach();
$direction->delete();
return redirect()->route('directions.index'); return redirect()->route('directions.index');
} }