Skip to content

Commit

Permalink
fix: eventcontroller related test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
blt950 committed Aug 2, 2024
1 parent 04507c8 commit 04beaed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/API/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ public function update(Request $request, Event $event)
$this->authorize('create', Event::class, $user);

$imageURL = $event->image;
$imageName = null;

if ($request->hasFile('image')) {
$image = $request->file('image');
$imageName = time() . '-' . uniqid() . '.' . $image->getClientOriginalExtension();
$imagePath = $image->getPathName();
$imageName = now()->format('Y-m-d') . '-' . uniqid() . '.' . $image->getClientOriginalExtension();

// Get image dimensions
list($width, $height) = getimagesize($imagePath);
list($width, $height) = getimagesize($image->getPathName());
if (round($width / $height, 2) != round(16 / 9, 2)) {
return back()->withErrors(['image' => 'Image must be in 16:9 aspect ratio.']);
}
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ public function update(Request $request, Event $event)
]);

$imageURL = $event->image;
$imageName = null;

if ($request->hasFile('image')) {
$image = $request->file('image');
$imageName = time() . '-' . uniqid() . '.' . $image->getClientOriginalExtension();
$imagePath = $image->getPathName();
$imageName = now()->format('Y-m-d') . '-' . uniqid() . '.' . $image->getClientOriginalExtension();

// Get image dimensions
list($width, $height) = getimagesize($imagePath);
list($width, $height) = getimagesize($image->getPathName());
if (round($width / $height, 2) != round(16 / 9, 2)) {
return back()->withErrors(['image' => 'Image must be in 16:9 aspect ratio.']);
}
Expand Down

0 comments on commit 04beaed

Please sign in to comment.