Update to laravel 12, other changes.
This commit is contained in:
@@ -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.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user