diff options
| author | Camil Staps | 2016-01-04 23:20:50 +0100 | 
|---|---|---|
| committer | Camil Staps | 2016-01-04 23:20:50 +0100 | 
| commit | 7a93b44c6cb2f1e1f335d93ddf62a149ebd5f1d9 (patch) | |
| tree | ea606ac400db5aced2a83f65efa247372ad164d5 /app | |
| parent | Models, migrations and seeds for root, roottranslation, stem, tense, verb (diff) | |
Training app
Diffstat (limited to 'app')
| -rw-r--r-- | app/Http/Controllers/RandomVerbController.php | 30 | ||||
| -rw-r--r-- | app/Http/routes.php | 12 | 
2 files changed, 41 insertions, 1 deletions
| diff --git a/app/Http/Controllers/RandomVerbController.php b/app/Http/Controllers/RandomVerbController.php new file mode 100644 index 0000000..e14d012 --- /dev/null +++ b/app/Http/Controllers/RandomVerbController.php @@ -0,0 +1,30 @@ +<?php +/** + * Created by PhpStorm. + * User: camil + * Date: 1/4/16 + * Time: 8:30 PM + */ + +namespace App\Http\Controllers; + +use HebrewParseTrainer\Verb; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Input; +use Laravel\Lumen\Routing\Controller as BaseController; + +class RandomVerbController extends BaseController { + +    public function show() +    { +        $verbs = Verb::all(); +        foreach (Input::get() as $col => $val) { +            $val = explode(',', $val); +            $verbs = $verbs->filter(function(Verb $item) use ($col, $val) { +                return in_array($item->getAttribute($col), $val); +            }); +        } +        return $verbs->random(); +    } + +}
\ No newline at end of file diff --git a/app/Http/routes.php b/app/Http/routes.php index 5ecfcd1..5e6bc5a 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -12,5 +12,15 @@  */  $app->get('/', function () use ($app) { -    return $app->welcome(); +    return view('trainer');  }); + +$app->get('/stem', function () use ($app) { +    return \HebrewParseTrainer\Stem::all(); +}); + +$app->get('/tense', function () use ($app) { +    return \HebrewParseTrainer\Tense::all(); +}); + +$app->get('/verb/random', 'RandomVerbController@show'); | 
