From b13d198a223143b8b53baa8c7c8261d3a8a42b05 Mon Sep 17 00:00:00 2001 From: Mariia <705283@student.inholland.nl> Date: Sun, 7 Apr 2024 15:10:37 +0200 Subject: [PATCH] some validation --- app/controller/artists/createArtist.php | 16 ++++--- app/controller/artists/editArtist.php | 18 ++++--- app/controller/jazzdays/createDay.php | 2 +- app/controller/jazzdays/editDay.php | 2 +- app/pages/admin/jazz/manage/artists.blade.php | 4 +- app/pages/admin/jazz/manage/days.blade.php | 6 ++- app/pages/admin/jazz/manage/passes.blade.php | 6 ++- .../admin/jazz/manage/performances.blade.php | 6 ++- app/pages/admin/jazz/manage/venues.blade.php | 6 ++- app/pages/jazz/artist/main.blade.php | 8 ++-- app/pages/jazz/artist/performances.blade.php | 2 +- app/pages/jazz/artist/songs.blade.php | 2 +- app/public/css/jazzStyles.css | 1 + app/public/img/jazz/artists/661294a308cd1.png | Bin 0 -> 1034987 bytes app/public/img/jazz/artists/6612969b16bd5.png | Bin 0 -> 659704 bytes .../img/jazz/performances/6612971c82aa8.png | Bin 0 -> 112023 bytes app/repository/JazzRepository.php | 35 ++------------ app/service/JazzService.php | 30 ++---------- app/service/ValidateInputService.php | 44 ++++++++++++++++-- 19 files changed, 101 insertions(+), 87 deletions(-) create mode 100644 app/public/img/jazz/artists/661294a308cd1.png create mode 100644 app/public/img/jazz/artists/6612969b16bd5.png create mode 100644 app/public/img/jazz/performances/6612971c82aa8.png diff --git a/app/controller/artists/createArtist.php b/app/controller/artists/createArtist.php index d29b668..a12f3a8 100644 --- a/app/controller/artists/createArtist.php +++ b/app/controller/artists/createArtist.php @@ -22,14 +22,18 @@ $bio = $props['bio']; $inputService->checkRequiredFields([$name, $bio]); + $inputService->validateArtistBio($bio); - $songs = [$_POST['song1'] ?? null, $_POST['song2'] ?? null, $_POST['song3'] ?? null]; - $albums = [$_POST['album1'] ?? null, $_POST['album2'] ?? null, $_POST['album3'] ?? null]; + $songs = [$props['song1'], $props['song2'], $props['song3']]; + $albums = [$props['album1'], $props['album2'], $props['album3']]; - $headerImgPath = $inputService->checkAndUploadImage('header_img', 'jazz/artists'); - $artistImg1Path = $inputService->checkAndUploadImage('artist_img1', 'jazz/artists'); - $artistImg2Path = $inputService->checkAndUploadImage('artist_img2', 'jazz/artists'); - $performanceImgPath = $inputService->checkAndUploadImage('performance_img', 'jazz/performances'); + $inputService->validateAlbums($albums); + $inputService->validateSongs($songs); + + $headerImgPath = $inputService->validateAndUploadImage('header_img', 'jazz/artists'); + $artistImg1Path = $inputService->validateAndUploadImage('artist_img1', 'jazz/artists'); + $artistImg2Path = $inputService->validateAndUploadImage('artist_img2', 'jazz/artists'); + $performanceImgPath = $inputService->validateAndUploadImage('performance_img', 'jazz/performances'); $jazzService->createArtist($name, $bio, $headerImgPath, $artistImg1Path, $artistImg2Path, $performanceImgPath, $songs, $albums); diff --git a/app/controller/artists/editArtist.php b/app/controller/artists/editArtist.php index cdfe19d..693c665 100644 --- a/app/controller/artists/editArtist.php +++ b/app/controller/artists/editArtist.php @@ -10,7 +10,7 @@ require_once __DIR__ . '/../../service/ValidateInputService.php'; $jazzService = new JazzService(); - + Route::serve('/artists/editArtist', function (array $props) use ($jazzService){ if(!isset($props['id'])) { Route::redirect('/artists/manageArtists'); @@ -33,14 +33,18 @@ $bio = $props['bio']; $validateInputService->checkRequiredFields([$name, $bio]); + $validateInputService->validateArtistBio($bio); + + $songs = [$props['song1'], $props['song2'], $props['song3']]; + $albums = [$props['album1'], $props['album2'], $props['album3']]; - $songs = [$_POST['song1'] ?? null, $_POST['song2'] ?? null, $_POST['song3'] ?? null]; - $albums = [$_POST['album1'] ?? null, $_POST['album2'] ?? null, $_POST['album3'] ?? null]; + $validateInputService->validateAlbums($albums); + $validateInputService->validateSongs($songs); - $headerImgPath = $validateInputService->handleImageUpload('header_img', 'jazz/artists'); - $artistImg1Path = $validateInputService->handleImageUpload('artist_img1', 'jazz/artists'); - $artistImg2Path = $validateInputService->handleImageUpload('artist_img2', 'jazz/artists'); - $performanceImgPath = $validateInputService->handleImageUpload('performance_img', 'jazz/performances'); + $headerImgPath = $validateInputService->updateImage('header_img', 'jazz/artists'); + $artistImg1Path = $validateInputService->updateImage('artist_img1', 'jazz/artists'); + $artistImg2Path = $validateInputService->updateImage('artist_img2', 'jazz/artists'); + $performanceImgPath = $validateInputService->updateImage('performance_img', 'jazz/performances'); $jazzService->updateArtist($id, $name, $bio, $songs, $albums, $headerImgPath, $artistImg1Path, $artistImg2Path, $performanceImgPath); diff --git a/app/controller/jazzdays/createDay.php b/app/controller/jazzdays/createDay.php index 9ac0122..4375061 100644 --- a/app/controller/jazzdays/createDay.php +++ b/app/controller/jazzdays/createDay.php @@ -28,7 +28,7 @@ $note = $props['note']; $validateInputService->checkRequiredFields([$date, $venueId]); - $imgPath = $validateInputService->checkAndUploadImage('image', 'jazz'); + $imgPath = $validateInputService->validateAndUploadImage('image', 'jazz'); $jazzService->createJazzDay($date, $venueId, $note, $imgPath); diff --git a/app/controller/jazzdays/editDay.php b/app/controller/jazzdays/editDay.php index 5af449b..097b1be 100644 --- a/app/controller/jazzdays/editDay.php +++ b/app/controller/jazzdays/editDay.php @@ -36,7 +36,7 @@ $note = $props['note']; $validateInputService->checkRequiredFields([$date, $venueId]); - $imgPath = $validateInputService->handleImageUpload('image', 'jazz'); + $imgPath = $validateInputService->updateImage('image', 'jazz'); $jazzService->updateJazzDay($dayId, $date, $venueId, $note, $imgPath); diff --git a/app/pages/admin/jazz/manage/artists.blade.php b/app/pages/admin/jazz/manage/artists.blade.php index 056d353..5314238 100644 --- a/app/pages/admin/jazz/manage/artists.blade.php +++ b/app/pages/admin/jazz/manage/artists.blade.php @@ -13,7 +13,9 @@ -
+ +@include('main.navbar') +