Initial Commit
This commit is contained in:
commit
9b22323711
36 changed files with 7164 additions and 0 deletions
43
routes/web.php
Normal file
43
routes/web.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?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);
|
||||
}]);
|
||||
Reference in a new issue