diff options
Diffstat (limited to 'app/Http/Controllers/RoscoLekoController.php')
-rw-r--r-- | app/Http/Controllers/RoscoLekoController.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/Http/Controllers/RoscoLekoController.php b/app/Http/Controllers/RoscoLekoController.php new file mode 100644 index 0000000..7058a26 --- /dev/null +++ b/app/Http/Controllers/RoscoLekoController.php @@ -0,0 +1,48 @@ +<?php + +namespace App\Http\Controllers; + +use Illuminate\Support\Facades\File; +use Illuminate\View\View; + +class RoscoLekoController extends Controller { + public function getImages(): array { + $images = []; + foreach (File::glob(public_path('images/rosco-leko').'/*') as $path) { + $image_data = []; + try { + $exif = exif_read_data($path); + } catch (Exception $ex) { + + } + $image_data["path"] = str_replace(public_path(), '', $path); + if (isset($exif)) { + if (isset($exif["ImageDescription"])) { + $image_data["description"] = $exif["ImageDescription"]; + } + if (isset($exif["DateTime"])) { + $image_data["date"] = strtotime($exif["DateTime"]); + } + } + array_push($images, $image_data); + } + + usort($images, function ($a, $b) { + $dateA = $a['date'] ?? PHP_INT_MIN; + $dateB = $b['date'] ?? PHP_INT_MIN; + return $dateB <=> $dateA; + }); + + return $images; + } + + /** + * Shows the page + * @return View + */ + public function show(): View { + return view('rosco-leko', [ + 'images' => $this->getImages(), + ]); + } +} |