<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    $dir = public_path().'/'.config('app.image.dir').'/backup/'.date('Y/m/d');
    
    $files = \File::allFiles($dir);
    $items = [];
	foreach ($files as $file) {
        $pstat = stat($file);
        $time = date('Y M D 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[] = $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::any('upload/image',"Upload@uploadFile");

