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
|
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue