diff --git a/config/app.php b/config/app.php index 018c3ae..f0a257a 100644 --- a/config/app.php +++ b/config/app.php @@ -67,7 +67,7 @@ return [ | */ - 'timezone' => 'UTC', + 'timezone' => 'Europe/Bratislava', /* |-------------------------------------------------------------------------- diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 4055649..dd9be27 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -186,9 +186,26 @@
Aktuálny obrázok z kamery
-
Galeria za aktualny deň
- - +
Galeria
+ @if (count($items) > 0) + + @if (count($items[0]) > 0) + + + + @endif + @if (isset($items[-1]) && count($items[-1]) > 0) + + + + @endif + @if (isset($items[-2]) && count($items[-2]) > 0) + + + + @endif + + @endif
diff --git a/routes/web.php b/routes/web.php index f6b3bda..e272abf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -11,28 +11,39 @@ | */ +Use Carbon\Carbon; + Route::get('/', function () { - $dir = public_path().'/'.config('app.image.dir').'/backup/'.date('Y/m/d'); - - date_default_timezone_set('Europe/Bratislava'); - $files = \File::allFiles($dir); + date_default_timezone_set(config('app.timezone')); $items = []; - foreach ($files as $file) { - $pstat = stat($file); - $time = date('d.m.Y H:i:s',$pstat['mtime']); + + for ($i=0; $i>=-2 ; $i-- ) { + $dt = Carbon::now()->add($i,'day'); + $dir = public_path().'/'.config('app.image.dir').'/backup/'.$dt->format('Y/m/d'); - $thumb_file = str_replace('backup','thumb',$file); - $item = ['src' => str_replace($_SERVER['DOCUMENT_ROOT'], '', $file), - 'thumbnail' => str_replace($_SERVER['DOCUMENT_ROOT'], '', $thumb_file), - 'w' => 1600, 'h' => 1200, 'title' => 'Time of photo: '. $time]; - $items[] = $item; + if (! \File::isDirectory($dir)) { + continue; } + $files = \File::allFiles($dir); + $items[$i] = []; + foreach ($files as $file) { + $pstat = stat($file); + $time = date('d.m.Y H:i:s',$pstat['mtime']); + + $thumb_file = str_replace('backup','thumb',$file); + $item = ['src' => str_replace($_SERVER['DOCUMENT_ROOT'], '', $file), + 'thumbnail' => str_replace($_SERVER['DOCUMENT_ROOT'], '', $thumb_file), + 'w' => 1600, 'h' => 1200, 'title' => 'Time of photo: '. $time]; + $items[$i][] = $item; + } + } return view('welcome')->with('items',$items); }); Route::get('/data',"MeasurementController@index"); Route::get('/data/get',"MeasurementController@get"); Route::get('/stats/get',"StatisticsController@get"); +Route::get('/images/get',"ImagesController@get"); Route::any('upload/image',"Upload@uploadFile");