diff --git a/app/controller/artistDetails.php b/app/controller/artistDetails.php
index 5e33c86..10dfe8a 100644
--- a/app/controller/artistDetails.php
+++ b/app/controller/artistDetails.php
@@ -16,8 +16,15 @@
$artist = $jazzService->getArtistById($artistId);
$performances = $jazzService->getPerformancesByArtist($artist);
+ $words = explode(' ', $artist->Bio);
+ $wordsPerPart = ceil(count($words) / 2);
+ $bioPart1 = implode(' ', array_slice($words, 0, $wordsPerPart));
+ $bioPart2 = implode(' ', array_slice($words, $wordsPerPart));
+
Route::render('jazz.artist.main', [
'artist' => $artist,
'performances' => $performances,
+ 'bioPart1' => $bioPart1,
+ 'bioPart2' => $bioPart2,
]);
});
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')
+
@include('admin.panel')
diff --git a/app/pages/admin/jazz/manage/days.blade.php b/app/pages/admin/jazz/manage/days.blade.php
index b611491..2c8988c 100644
--- a/app/pages/admin/jazz/manage/days.blade.php
+++ b/app/pages/admin/jazz/manage/days.blade.php
@@ -13,7 +13,11 @@
-
+
+
+@include('main.navbar')
+
+
@include('admin.panel')
diff --git a/app/pages/admin/jazz/manage/passes.blade.php b/app/pages/admin/jazz/manage/passes.blade.php
index 9073921..98ccc3f 100644
--- a/app/pages/admin/jazz/manage/passes.blade.php
+++ b/app/pages/admin/jazz/manage/passes.blade.php
@@ -13,7 +13,11 @@
-
+
+
+@include('main.navbar')
+
+
@include('admin.panel')
diff --git a/app/pages/admin/jazz/manage/performances.blade.php b/app/pages/admin/jazz/manage/performances.blade.php
index 3050aa9..cccb494 100644
--- a/app/pages/admin/jazz/manage/performances.blade.php
+++ b/app/pages/admin/jazz/manage/performances.blade.php
@@ -13,7 +13,11 @@
-
+
+
+@include('main.navbar')
+
+
diff --git a/app/pages/admin/jazz/manage/venues.blade.php b/app/pages/admin/jazz/manage/venues.blade.php
index 638537c..4eb3f8f 100644
--- a/app/pages/admin/jazz/manage/venues.blade.php
+++ b/app/pages/admin/jazz/manage/venues.blade.php
@@ -13,7 +13,11 @@
-
+
+
+@include('main.navbar')
+
+
@include('admin.panel')
diff --git a/app/pages/jazz/artist/albums.blade.php b/app/pages/jazz/artist/albums.blade.php
index e69de29..5499e9a 100644
--- a/app/pages/jazz/artist/albums.blade.php
+++ b/app/pages/jazz/artist/albums.blade.php
@@ -0,0 +1,12 @@
+
\ No newline at end of file
diff --git a/app/pages/jazz/artist/header.blade.php b/app/pages/jazz/artist/header.blade.php
index e69de29..b03ba86 100644
--- a/app/pages/jazz/artist/header.blade.php
+++ b/app/pages/jazz/artist/header.blade.php
@@ -0,0 +1,7 @@
+
+
+
+ {{ $artist->Name }}
+
+
+
\ No newline at end of file
diff --git a/app/pages/jazz/artist/main.blade.php b/app/pages/jazz/artist/main.blade.php
index 71eca13..d04c6eb 100644
--- a/app/pages/jazz/artist/main.blade.php
+++ b/app/pages/jazz/artist/main.blade.php
@@ -13,151 +13,78 @@
-
-
- @if ($artist->HeaderImg)
-
- @else
-
-
Header Image
- @endif
+@include('main.navbar')
-
-
- {{ $artist->Name }}
-
-
+@include('jazz.artist.header')
+
+
+
+ Biography of {{ $artist->Name }}
+
-
-
-
-
- @php
- $bioPart1 = 'Some bio';
- $bioPart2 = 'Some bio';
- if($artist->Bio){
- $words = explode(' ', $artist->Bio);
- $wordsPerPart = ceil(count($words) / 2);
- $bioPart1 = implode(' ', array_slice($words, 0, $wordsPerPart));
- $bioPart2 = implode(' ', array_slice($words, $wordsPerPart));
- }
- @endphp
-
+
+
+
-
- @if($artist->ArtistImg1)
-
- @else
-
Image
- @endif
+
+
+
+
+
-
- @if($artist->ArtistImg2)
-
- @else
-
Image
- @endif
+
+
+
+
+
-
-
-
-
- Discover albums of {{ $artist->Name }}!
-
-
-
- @foreach ($artist->Albums as $album)
-
- @endforeach
+
+
+
+ Discover albums of {{ $artist->Name }}
+
-
-
-
-
-
- Discover most popular songs of {{ $artist->Name }}!
-
-
-
-
- @foreach ($artist->Songs as $song)
-
- @endforeach
+
+
+ @foreach ($artist->Albums as $album)
+ @include('jazz.artist.albums')
+ @endforeach
+
-
-
-@foreach ($performances as $performance)
-
-
-
- Come to {{ $performance->Day->Venue->Name }}
- on {{ date('j F', strtotime($performance->StartDateTime)) }}
- to enjoy {{ $artist->Name }}'s music!
- {{ date('H:i', strtotime($performance->StartDateTime)) }}
- - {{ date('H:i', strtotime($performance->EndDateTime)) }}
- @if (trim($performance->Details) !== '')
- | {{ $performance->Details }}
- @endif
- @if ($performance->Price != '0.00')
- - € {{ number_format($performance->Price, 2) }}
- @endif
-
- @if ($performance->Price != '0.00')
-
- @if ($performance->AvailableTickets > 0)
-
- Buy Tickets!
- @else
-
- Sold Out
-
- @endif
-
- @else
-
-
- For free!
-
-
- @endif
+
+
+
+ Discover most popular songs of {{ $artist->Name }}!
+
+
+
+
+ @foreach ($artist->Songs as $song)
+ @include('jazz.artist.songs')
+ @endforeach
-@endforeach
+
+ @include('jazz.artist.performances')
+
+ @include('main.footer')
+
diff --git a/app/pages/jazz/artist/performances.blade.php b/app/pages/jazz/artist/performances.blade.php
index e69de29..4490182 100644
--- a/app/pages/jazz/artist/performances.blade.php
+++ b/app/pages/jazz/artist/performances.blade.php
@@ -0,0 +1,39 @@
+
+
+@foreach ($performances as $performance)
+
+
+
+ Come to {{ $performance->Day->Venue->Name }}
+ on {{ date('j F', strtotime($performance->StartDateTime)) }}
+ to enjoy {{ $artist->Name }}'s music!
+ {{ date('H:i', strtotime($performance->StartDateTime)) }}
+ - {{ date('H:i', strtotime($performance->EndDateTime)) }}
+ @if (trim($performance->Details) !== '')
+ | {{ $performance->Details }}
+ @endif
+ @if ($performance->Price != '0.00')
+ - € {{ number_format($performance->Price, 2) }}
+ @endif
+
+ @if ($performance->Price != '0.00')
+
+ @if ($performance->AvailableTickets > 0)
+
+ Buy Tickets!
+ @else
+
+ Sold Out
+
+ @endif
+
+ @else
+
+
+ For free!
+
+
+ @endif
+
+
+@endforeach
\ No newline at end of file
diff --git a/app/pages/jazz/artist/songs.blade.php b/app/pages/jazz/artist/songs.blade.php
index e69de29..1ab8bcb 100644
--- a/app/pages/jazz/artist/songs.blade.php
+++ b/app/pages/jazz/artist/songs.blade.php
@@ -0,0 +1,12 @@
+
\ No newline at end of file
diff --git a/app/pages/jazz/overview/artists.blade.php b/app/pages/jazz/overview/artists.blade.php
index e69de29..06da96b 100644
--- a/app/pages/jazz/overview/artists.blade.php
+++ b/app/pages/jazz/overview/artists.blade.php
@@ -0,0 +1,15 @@
+
\ No newline at end of file
diff --git a/app/pages/jazz/overview/header.blade.php b/app/pages/jazz/overview/header.blade.php
index e69de29..3330cc2 100644
--- a/app/pages/jazz/overview/header.blade.php
+++ b/app/pages/jazz/overview/header.blade.php
@@ -0,0 +1,13 @@
+
+
+
+
+ {{ $festivalEvent->getFestivalEventName() }}
+
+
+ {{ date('j F', strtotime($festivalEvent->getStartDate())) }} -
+ {{ date('j F', strtotime($festivalEvent->getEndDate())) }}
+
+
+
+
diff --git a/app/pages/jazz/overview/main.blade.php b/app/pages/jazz/overview/main.blade.php
index 2ceba69..05869b2 100644
--- a/app/pages/jazz/overview/main.blade.php
+++ b/app/pages/jazz/overview/main.blade.php
@@ -5,143 +5,43 @@
{{ $festivalEvent->getFestivalEventName() }}
-
+
@include('main.navbar')
-
-
-
-
-
- {{ $festivalEvent->getFestivalEventName() }}
-
-
- {{ date('j F', strtotime($festivalEvent->getStartDate())) }} -
- {{ date('j F', strtotime($festivalEvent->getEndDate())) }}
-
-
-
-
-
+@include('jazz.overview.header')
+
+
+
{{ $festivalEvent->getDescription() }}
-
+
🔊
-
-
+
+
+
{{ $festivalEvent->getTitle() }}
-
@foreach ($eventDays as $dayNumber => $eventDay)
-
-
-
- DAY {{ $dayNumber + 1 }} -
- {{ date('l, F jS', strtotime($eventDay['day']->Date)) }} 📍
-
- {{ $eventDay['day']->Venue->Name }}
-
- {{ $eventDay['day']->Venue->Name }}
- {{ $eventDay['day']->Venue->Address }}
- {{ $eventDay['day']->Venue->ContactDetails }}
- @if (!empty($eventDay['day']->Note))
- {{ $eventDay['day']->Note }}
- @endif
-
-
-
-
+ @include('jazz.overview.venue')
-
-
-
-
-
- @foreach ($eventDay['performances'] as $index => $performance)
-
-
-
- {{ $performance->Artist->Name }}
- {{ date('H:i', strtotime($performance->StartDateTime)) }}
- - {{ date('H:i', strtotime($performance->EndDateTime)) }}
- @if (!empty($performance->Details))
- | {{ $performance->Details }}
- @endif
- @if ($performance->Price != '0.00')
- - € {{ number_format($performance->Price, 2) }}
- @else
- - Free!
- @endif
-
- @if ($performance->Price != '0.00')
- @if ($performance->AvailableTickets > 0)
-
- Buy Tickets!
- @else
-
- Sold Out
-
- @endif
- @endif
-
-
- @endforeach
-
-
- @php $passesStartOffset = count($eventDay['performances']) * 80 + 40; @endphp
- @foreach ($eventDay['passes'] as $index => $pass)
-
-
-
- {{ $pass->Note }}
- Price: €{{ number_format($pass->Price, 2) }}
-
- @if($pass->AvailableTickets > 0)
-
- Buy Jazz Pass!
-
- @else
-
- Sold Out
-
- @endif
-
-
- @endforeach
-
+
+ @include('jazz.overview.schedule')
+ @include('jazz.overview.passes')
-
-
-
+ @include('jazz.overview.artists')
+
@endforeach
@include('main.footer')
diff --git a/app/pages/jazz/overview/passes.blade.php b/app/pages/jazz/overview/passes.blade.php
new file mode 100644
index 0000000..9ff8c55
--- /dev/null
+++ b/app/pages/jazz/overview/passes.blade.php
@@ -0,0 +1,20 @@
+@php $passesStartOffset = count($eventDay['performances']) * 80 + 40; @endphp
+@foreach ($eventDay['passes'] as $index => $pass)
+
+
+
+ {{ $pass->Note }}
+ Price: €{{ number_format($pass->Price, 2) }}
+
+ @if($pass->AvailableTickets > 0)
+
+ Buy Jazz Pass!
+
+ @else
+
+ Sold Out
+
+ @endif
+
+
+@endforeach
\ No newline at end of file
diff --git a/app/pages/jazz/overview/schedule.blade.php b/app/pages/jazz/overview/schedule.blade.php
new file mode 100644
index 0000000..66402a9
--- /dev/null
+++ b/app/pages/jazz/overview/schedule.blade.php
@@ -0,0 +1,30 @@
+@foreach ($eventDay['performances'] as $index => $performance)
+
+
+
+ {{ $performance->Artist->Name }}
+ {{ date('H:i', strtotime($performance->StartDateTime)) }}
+ - {{ date('H:i', strtotime($performance->EndDateTime)) }}
+ @if (!empty($performance->Details))
+ | {{ $performance->Details }}
+ @endif
+ @if ($performance->Price != '0.00')
+ - € {{ number_format($performance->Price, 2) }}
+ @else
+ - Free!
+ @endif
+
+ @if ($performance->Price != '0.00')
+ @if ($performance->AvailableTickets > 0)
+
+ Buy Tickets!
+
+ @else
+
+ Sold Out
+
+ @endif
+ @endif
+
+
+@endforeach
diff --git a/app/pages/jazz/overview/venue.blade.php b/app/pages/jazz/overview/venue.blade.php
index e69de29..79b7e79 100644
--- a/app/pages/jazz/overview/venue.blade.php
+++ b/app/pages/jazz/overview/venue.blade.php
@@ -0,0 +1,17 @@
+
+
+ DAY {{ $dayNumber + 1 }} -
+ {{ date('l, F jS', strtotime($eventDay['day']->Date)) }} 📍
+
+ {{ $eventDay['day']->Venue->Name }}
+
+ {{ $eventDay['day']->Venue->Name }}
+ {{ $eventDay['day']->Venue->Address }}
+ {{ $eventDay['day']->Venue->ContactDetails }}
+ @if (!empty($eventDay['day']->Note))
+ {{ $eventDay['day']->Note }}
+ @endif
+
+
+
+
\ No newline at end of file
diff --git a/app/pages/main/navbar.blade.php b/app/pages/main/navbar.blade.php
index f5f592e..de2e5fd 100644
--- a/app/pages/main/navbar.blade.php
+++ b/app/pages/main/navbar.blade.php
@@ -1,20 +1,27 @@
-
-
-
- Haarlem
-
+
+
+
diff --git a/app/public/css/jazzStyles.css b/app/public/css/jazzStyles.css
index beb53d5..eacd327 100644
--- a/app/public/css/jazzStyles.css
+++ b/app/public/css/jazzStyles.css
@@ -26,28 +26,22 @@
opacity: 1;
}
+.artist-card:hover .artist-image {
+ filter: brightness(50%);
+}
+
+.artist-card:hover .overlay {
+ opacity: 1;
+}
+
.artist-card {
overflow: hidden;
background-color: #b92090;
position: relative;
- /* This ensures the overlay is positioned relative to the artist-card */
}
.artist-image {
display: block;
- max-width: 100%;
- height: auto;
- width: auto;
- max-height: 200px;
- object-fit: cover;
-}
-
-.artist-card:hover .artist-image {
- filter: brightness(50%);
-}
-
-.artist-card:hover .overlay {
- opacity: 1;
}
.overlay {
@@ -61,4 +55,7 @@
font-size: 1.5rem;
font-weight: bold;
pointer-events: none;
-}
\ No newline at end of file
+}
+
+
+
diff --git a/app/public/css/navBarStyle.css b/app/public/css/navBarStyle.css
new file mode 100644
index 0000000..a237d36
--- /dev/null
+++ b/app/public/css/navBarStyle.css
@@ -0,0 +1,13 @@
+@media (min-width: 768px) {
+ #stickyNav {
+ position: sticky;
+ top: 0;
+ z-index: 50;
+ }
+}
+
+@media (max-width: 767px) {
+ #stickyNav {
+ position: static;
+ }
+}
diff --git a/app/public/img/jazz/artists/661294a308cd1.png b/app/public/img/jazz/artists/661294a308cd1.png
new file mode 100644
index 0000000..4c4c780
Binary files /dev/null and b/app/public/img/jazz/artists/661294a308cd1.png differ
diff --git a/app/public/img/jazz/artists/6612969b16bd5.png b/app/public/img/jazz/artists/6612969b16bd5.png
new file mode 100644
index 0000000..4d3503f
Binary files /dev/null and b/app/public/img/jazz/artists/6612969b16bd5.png differ
diff --git a/app/public/img/jazz/performances/6612971c82aa8.png b/app/public/img/jazz/performances/6612971c82aa8.png
new file mode 100644
index 0000000..e900fbe
Binary files /dev/null and b/app/public/img/jazz/performances/6612971c82aa8.png differ
diff --git a/app/repository/JazzRepository.php b/app/repository/JazzRepository.php
index 55568bd..03cf511 100644
--- a/app/repository/JazzRepository.php
+++ b/app/repository/JazzRepository.php
@@ -30,7 +30,7 @@ public function getArtistById(int $id): Artist
public function getAllArtists(): array
{
- $query = $this->connection->prepare('SELECT * FROM Artist');
+ $query = $this->connection->prepare('SELECT * FROM Artist ORDER BY Name ASC');
$query->execute();
$artistData = $query->fetchAll(\PDO::FETCH_ASSOC);
@@ -67,13 +67,6 @@ private function createArtistFromData(array $artistData): Artist
}
// create edit delete artists
- public function updateArtist1(int $artistId, string $name, string $bio, array $songs, array $albums, string $headerImg, string $artistImg1, string $artistImg2, string $performanceImg): bool
- {
- $query = $this->connection->prepare('UPDATE Artist SET Name = ?, Bio = ?, HeaderImg = ?, ArtistImg1 = ?, ArtistImg2 = ?, PerformanceImg = ?, Song1 = ?, Song2 = ?, Song3 = ?, Album1 = ?, Album2 = ?, Album3 = ? WHERE ArtistID = ?');
-
- return $query->execute([$name, $bio, $headerImg, $artistImg1, $artistImg2, $performanceImg, $songs[0], $songs[1], $songs[2], $albums[0], $albums[1], $albums[2], $artistId]);
- }
-
public function updateArtist(int $artistId, string $name, string $bio, array $songs, array $albums, ?string $headerImg = null, ?string $artistImg1 = null, ?string $artistImg2 = null, ?string $performanceImg = null): bool
{
$sql = 'UPDATE Artist SET Name = ?, Bio = ?';
@@ -223,23 +216,6 @@ public function getAllJazzDays(): array
return $jazzDays;
}
- public function getAllJazzDaysByVenueId($id): array
- {
- $query = $this->connection->prepare('SELECT d.*, v.VenueID, v.Name as VenueName, v.Address, v.ContactDetails FROM JazzDay d
- JOIN Venue v ON d.VenueID = v.VenueID
- WHERE d.VenueID = ?');
- $query->execute([$id]);
-
- $jazzDaysData = $query->fetchAll(\PDO::FETCH_ASSOC);
- $jazzDays = [];
-
- foreach ($jazzDaysData as $jazzDayData) {
- $jazzDays[] = $this->createJazzDayFromData($jazzDayData);
- }
-
- return $jazzDays;
- }
-
private function createJazzDayFromData(array $jazzDayData): JazzDay
{
$venue = $this->createVenueFromData($jazzDayData);
@@ -300,11 +276,10 @@ public function deleteJazzDay(int $id): bool
// retrieve performances
public function getPerformancesByArtist(Artist $artist): array
{
-
$query = $this->connection->prepare('SELECT p.*, j.*, v.VenueID, v.Name as VenueName, v.Address, v.ContactDetails FROM Performance p
LEFT JOIN JazzDay j ON p.DayID = j.DayID
LEFT JOIN Venue v ON j.VenueID = v.VenueID
- WHERE p.ArtistID = ?');
+ WHERE p.ArtistID = ? ORDER BY p.StartDateTime');
$query->execute([$artist->ArtistID]);
$performanceData = $query->fetchAll(\PDO::FETCH_ASSOC);
@@ -319,7 +294,7 @@ public function getPerformancesByArtist(Artist $artist): array
public function getPerformancesByJazzDay(JazzDay $day): array
{
- $query = $this->connection->prepare('SELECT p.*, a.* FROM Performance p LEFT JOIN Artist a ON p.ArtistID = a.ArtistID WHERE p.DayID = ?');
+ $query = $this->connection->prepare('SELECT p.*, a.* FROM Performance p LEFT JOIN Artist a ON p.ArtistID = a.ArtistID WHERE p.DayID = ? ORDER BY p.StartDateTime');
$query->execute([$day->DayID]);
$performanceData = $query->fetchAll(\PDO::FETCH_ASSOC);
@@ -336,7 +311,7 @@ public function getAllPerformances(): array
$query = $this->connection->prepare('SELECT p.*, a.*, j.*, v.VenueID, v.Name as VenueName, v.Address, v.ContactDetails FROM Performance p
LEFT JOIN Artist a ON p.ArtistID = a.ArtistID
LEFT JOIN JazzDay j ON p.DayID = j.DayID
- LEFT JOIN Venue v ON j.VenueID = v.VenueID');
+ LEFT JOIN Venue v ON j.VenueID = v.VenueID ORDER BY p.StartDateTime');
$query->execute();
$performanceData = $query->fetchAll(\PDO::FETCH_ASSOC);
@@ -434,7 +409,7 @@ public function getJazzPassById(int $id): JazzPass
public function getAllJazzPasses(): array
{
- $query = $this->connection->prepare('SELECT * FROM JazzPass');
+ $query = $this->connection->prepare('SELECT * FROM JazzPass order by StartDateTime ASC');
$query->execute();
$passesData = $query->fetchAll(\PDO::FETCH_ASSOC);
diff --git a/app/service/JazzService.php b/app/service/JazzService.php
index da7881c..1611cd8 100644
--- a/app/service/JazzService.php
+++ b/app/service/JazzService.php
@@ -37,14 +37,14 @@ public function getAllArtists(): array
return $this->repository->getAllArtists();
}
- public function updateArtist(int $artistId, string $name, string $bio, ?array $songs, ?array $albums, ?string $headerImg, ?string $artistImg1, ?string $artistImg2, ?string $performanceImg): void
+ public function updateArtist(int $artistId, string $name, string $bio, array $songs, array $albums, ?string $headerImg, ?string $artistImg1, ?string $artistImg2, ?string $performanceImg): void
{
$artist = $this->repository->getArtistById($artistId);
- $this->setDefaultSongsAndAlbumsIfEmpty($songs, $albums);
$this->repository->updateArtist($artistId, $name, $bio, $songs, $albums, $headerImg, $artistImg1, $artistImg2, $performanceImg);
- // delete old images if new were uploaded and if old images aren't placeholders
+ // if the user updated image , delete the old one
+ // if the image is a placeholder don't delete it
if ($headerImg !== null && $artist->HeaderImg !== '/img/jazz/artists/artistPlaceholder.jpg') {
$this->imageService->deleteImage($artist->HeaderImg);
}
@@ -61,8 +61,6 @@ public function updateArtist(int $artistId, string $name, string $bio, ?array $s
public function createArtist(string $name, string $bio, string $headerImg, string $artistImg1, string $artistImg2, string $performanceImg, array $songs, array $albums): bool
{
- $this->setDefaultSongsAndAlbumsIfEmpty($songs, $albums);
-
return $this->repository->createArtist($name, $bio, $headerImg, $artistImg1, $artistImg2, $performanceImg, $songs, $albums);
}
@@ -88,28 +86,6 @@ public function deleteArtist(int $id): void
}
}
- private function setDefaultSongsAndAlbumsIfEmpty(array &$songs, array &$albums): void
- {
- if ($albums[0] == null) {
- $albums[0] = '7oBC2PuPSvXkLEZdoCxsv5';
- }
- if ($albums[1] == null) {
- $albums[1] = '18g4jSwIbYcbJI5U7PIzMz';
- }
- if ($albums[2] == null) {
- $albums[2] = '0B7DKUR00yRXncWrlQwIR6';
- }
- if ($songs[0] == null) {
- $songs[0] = '6XQHlsNu6so4PdglFkJQRJ';
- }
- if ($songs[1] == null) {
- $songs[1] = '2VvDKx7lzdarObpQFn1iAh';
- }
- if ($songs[2] == null) {
- $songs[2] = '1otrWVcbCxemNnn7eiKW1P';
- }
- }
-
// venues
public function getVenueById(int $id): Venue
{
diff --git a/app/service/ValidateInputService.php b/app/service/ValidateInputService.php
index ac5e443..77bec7a 100644
--- a/app/service/ValidateInputService.php
+++ b/app/service/ValidateInputService.php
@@ -53,7 +53,7 @@ public function validateDate($startDate, $endDate): void
}
}
-
+
public function validateEmptyNumbers($numbers): void
{
foreach($numbers as $number) {
@@ -74,7 +74,7 @@ public function validateTicketFields($availableTickets, $totalTickets): void
}
}
- public function checkAndUploadImage($image, $dir) {
+ public function validateAndUploadImage($image, $dir) {
if (isset($_FILES[$image]) && $_FILES[$image]['error'] === UPLOAD_ERR_OK) {
try {
return $this->imageService->uploadImage($_FILES[$image], $dir);
@@ -83,13 +83,14 @@ public function checkAndUploadImage($image, $dir) {
exit();
}
} else {
- $error = 'Please upload an image.';
+ $imgName = str_replace(['_', ' '], '', $image);
+ $error = "Please upload an image {$imgName}.";
echo "$error
";
exit();
}
}
- function handleImageUpload($image, $dir)
+ function updateImage($image, $dir)
{
if (isset($_FILES[$image]) && $_FILES[$image]['error'] === UPLOAD_ERR_OK) {
try {
@@ -102,4 +103,39 @@ function handleImageUpload($image, $dir)
return null;
}
}
+
+ public function validateArtistBio($bio): void
+ {
+ if (strlen($bio) < 800) {
+ $error = 'Bio should not be less then 800 characters (around 150 words).';
+ echo "$error
";
+ exit();
+ }
+ }
+
+ public function validateAlbums(array &$albums): void
+ {
+ if (strlen($albums[0]) < 22) {
+ $albums[0] = '7oBC2PuPSvXkLEZdoCxsv5';
+ }
+ if (strlen($albums[1]) < 22) {
+ $albums[1] = '18g4jSwIbYcbJI5U7PIzMz';
+ }
+ if (strlen($albums[2]) < 22) {
+ $albums[2] = '0B7DKUR00yRXncWrlQwIR6';
+ }
+ }
+
+ public function validateSongs(array &$songs): void
+ {
+ if (strlen($songs[0]) < 22) {
+ $songs[0] = '6XQHlsNu6so4PdglFkJQRJ';
+ }
+ if (strlen($songs[1]) < 22) {
+ $songs[1] = '2VvDKx7lzdarObpQFn1iAh';
+ }
+ if (strlen($songs[2]) < 22) {
+ $songs[2] = '1otrWVcbCxemNnn7eiKW1P';
+ }
+ }
}
\ No newline at end of file