Tour-Anlage robuster machen und App-Logging erweitern
This commit is contained in:
parent
4c9a48e79f
commit
c64fa427b3
8 changed files with 232 additions and 17 deletions
|
|
@ -122,26 +122,58 @@ class TourController
|
|||
|
||||
public function store(): void
|
||||
{
|
||||
app_log('info', 'Tour create attempt', [
|
||||
'name' => input('name'),
|
||||
'start' => input('start'),
|
||||
'deadline' => input('deadline'),
|
||||
'max_participants' => input('max_participants'),
|
||||
'is_cancelled' => input('is_cancelled'),
|
||||
'tour_guide_id' => input('tour_guide_id'),
|
||||
'has_image' => !empty($_FILES['bild']['name']),
|
||||
'image_name' => $_FILES['bild']['name'] ?? null,
|
||||
'image_size' => $_FILES['bild']['size'] ?? null,
|
||||
]);
|
||||
|
||||
validate([
|
||||
'name' => 'required|min:3',
|
||||
'beschreibung' => 'required',
|
||||
'start' => 'required',
|
||||
'deadline' => 'required',
|
||||
'tour_guide_id' => 'required',
|
||||
'bild' => 'mimes:jpg,jpeg,bmp,png,gif',
|
||||
]);
|
||||
|
||||
$tour = Tour::create([
|
||||
'name' => (string) input('name'),
|
||||
'tour_guide_id' => (int) input('tour_guide_id'),
|
||||
'beschreibung' => (string) input('beschreibung'),
|
||||
'start' => db_date(input('start')),
|
||||
'deadline' => db_date(input('deadline')),
|
||||
'max_participants' => (int) (input('max_participants') ?: 5),
|
||||
'is_cancelled' => (bool) input('is_cancelled', false),
|
||||
'bericht' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
try {
|
||||
$tour = Tour::create([
|
||||
'name' => (string) input('name'),
|
||||
'tour_guide_id' => (int) input('tour_guide_id'),
|
||||
'beschreibung' => (string) input('beschreibung'),
|
||||
'start' => db_date(input('start')),
|
||||
'deadline' => db_date(input('deadline')),
|
||||
'max_participants' => (int) (input('max_participants') ?: 5),
|
||||
'is_cancelled' => (bool) input('is_cancelled', false),
|
||||
'bericht' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
app_log('error', 'Tour create failed', [
|
||||
'exception' => $e::class,
|
||||
'error' => $e->getMessage(),
|
||||
'name' => input('name'),
|
||||
'start' => input('start'),
|
||||
'deadline' => input('deadline'),
|
||||
]);
|
||||
|
||||
$_SESSION['_old'] = $_POST;
|
||||
flash_set('error', 'Die Tour konnte nicht gespeichert werden. Bitte den Administrator informieren.');
|
||||
redirect('/tour/create');
|
||||
}
|
||||
|
||||
app_log('info', 'Tour created', [
|
||||
'tour_id' => $tour->id,
|
||||
'name' => $tour->name,
|
||||
'start' => $tour->start,
|
||||
'tour_guide_id' => $tour->tour_guide_id,
|
||||
]);
|
||||
|
||||
if (!empty($_FILES['bild']['name'])) {
|
||||
|
|
@ -152,6 +184,14 @@ class TourController
|
|||
error_log('Tourbild-Upload: ' . $e);
|
||||
}
|
||||
|
||||
app_log('error', 'Tour image upload failed', [
|
||||
'tour_id' => $tour->id,
|
||||
'exception' => $e::class,
|
||||
'error' => $e->getMessage(),
|
||||
'image_name' => $_FILES['bild']['name'] ?? null,
|
||||
'image_size' => $_FILES['bild']['size'] ?? null,
|
||||
]);
|
||||
|
||||
flash_set('error', $e instanceof \RuntimeException
|
||||
? $e->getMessage()
|
||||
: 'Das Bild konnte nicht verarbeitet werden.');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue