1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
sexelleryoga/routes/web.php
2020-10-03 16:07:18 +02:00

43 lines
1.1 KiB
PHP

<?php
use Illuminate\Support\Facades\Crypt;
use Illuminate\Container\Container;
use Illuminate\Http\Request;
use App\Models\Word;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$router->get('/', function() {
return redirect()->route('word', [ 'uuid' => Word::getRandom() ]);
});
$router->get('/{uuid}[/{guess}]', ['as' => 'word', function($uuid, $guess = false) {
$word = Word::where('uuid', $uuid)->first();
if (!$word) {
abort(404);
}
$params = [
'uuid' => $uuid,
'word' => $word->value
];
if ($guess !== false) {
$params['guess'] = $guess;
$params['correct'] = $guess === $word->type;
$params['next'] = Word::getRandom($uuid);
return view('result', $params);
}
return view('main', $params);
}]);