Update to laravel 12, other changes.

This commit is contained in:
Simon Pocrnjič
2025-03-25 21:38:24 +01:00
parent 0f8cfd3f16
commit 86a021143a
22 changed files with 2820 additions and 1504 deletions
+27 -19
View File
@@ -4,6 +4,8 @@
use App\Models\ClientCase;
use App\Models\Contract;
use Exception;
use Illuminate\Database\QueryException;
use Illuminate\Http\Request;
use Inertia\Inertia;
@@ -121,26 +123,32 @@ public function updateContract(ClientCase $clientCase, String $uuid, Request $re
}
public function storeActivity(ClientCase $clientCase, Request $request) {
$attributes = $request->validate([
'due_date' => 'nullable|date',
'amount' => 'nullable|decimal:0,4',
'note' => 'string',
'action_id' => 'exists:\App\Models\Action,id',
'decision_id' => 'exists:\App\Models\Decision,id'
]);
//Create activity
$activity = $clientCase->activities()->create($attributes);
foreach ($activity->decision->events as $e) {
$class = '\\App\\Events\\' . $e->name;
event(new $class($clientCase));
}
try {
$attributes = $request->validate([
'due_date' => 'nullable|date',
'amount' => 'nullable|decimal:0,4',
'note' => 'nullable|string',
'action_id' => 'exists:\App\Models\Action,id',
'decision_id' => 'exists:\App\Models\Decision,id'
]);
return to_route('clientCase.show', $clientCase);
//Create activity
$row = $clientCase->activities()->create($attributes);
/*foreach ($activity->decision->events as $e) {
$class = '\\App\\Events\\' . $e->name;
event(new $class($clientCase));
}*/
logger()->info('Activity successfully inserted', $attributes);
return to_route('clientCase.show', $clientCase)->with('success', 'Successful created!');
} catch (QueryException $e) {
logger()->error('Database error occurred:', ['error' => $e->getMessage()]);
return back()->with('error', 'Failed to insert activity. ' . $e->getMessage());
} catch (Exception $e) {
logger()->error('An unexpected error occurred:', ['error' => $e->getMessage()]);
// Return a generic error response
return back()->with('error', 'An unexpected error occurred. Please try again later.');
}
}