change strcture controller becuse repet some code in 3 file and get same code in model

This commit is contained in:
2025-11-09 15:25:00 +03:30
parent a619efb123
commit 40513d72b8
7 changed files with 250 additions and 492 deletions

View File

@@ -34,29 +34,17 @@ class ProvinceOfficeController extends Controller
return response()->json($data);
}
public function feedback(FeedBackRequest $request, Harim $harim): JsonResponse
{
DB::transaction(function () use ($request, $harim) {
$action = HarimAction::FEEDBACK->value;
$harim->histories()->create([
'expert_id' => auth()->user()->id,
'previous_state_id' => $harim->state_id,
'previous_state_name' => $harim->state_name,
'expert_description' => $request->expert_description,
'action_id' => $action,
'action_name' => HarimAction::name($action),
]);
$state = HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value;
$harim->update([
'state_id' => $state,
'state_name' => HarimStates::name($state),
$harim->updateStateWithHistory(
action:HarimAction::FEEDBACK->value,
description: $request->expert_description,
data: [
'state_id' => HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value,
'state_name' => HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->label(),
'forbidden_area' => $request->input('forbidden_area'),
]);
});
]
);
return $this->successResponse();
}