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