forked from aslan/applicant-site
update logic for delete direction
This commit is contained in:
parent
04d596b0eb
commit
f1ffe64ef3
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue