diff options
| author | Camil Staps | 2016-09-06 00:23:26 +0200 | 
|---|---|---|
| committer | Camil Staps | 2016-09-06 00:23:26 +0200 | 
| commit | 6f6a6abe3c9971b60aad585a198ced6c51329ef5 (patch) | |
| tree | a6a5300eb572c1306c34d1f400a928eb2a68f631 /app/Http | |
| parent | Add roots (diff) | |
Different root kinds instead of only strong/weak
Diffstat (limited to 'app/Http')
| -rw-r--r-- | app/Http/Controllers/RootController.php | 24 | 
1 files changed, 21 insertions, 3 deletions
| diff --git a/app/Http/Controllers/RootController.php b/app/Http/Controllers/RootController.php index e3cf3e1..3899754 100644 --- a/app/Http/Controllers/RootController.php +++ b/app/Http/Controllers/RootController.php @@ -18,19 +18,37 @@   */  namespace App\Http\Controllers; -use HebrewParseTrainer\Root; -  use Illuminate\Http\Request;  use Illuminate\Support\Facades\Auth;  use Illuminate\Support\Facades\Validator;  use Laravel\Lumen\Routing\Controller as BaseController; +use HebrewParseTrainer\Root; +use HebrewParseTrainer\RootKind; +  class RootController extends BaseController {  	public function create(Request $request) { +		$_kinds = RootKind::all(); +		$kinds = []; +		foreach ($_kinds as $kind) +			$kinds[] = $kind->id; + +		$validator = Validator::make($request->input(), [ +			'root'         => 'required', +			'root_kind_id' => 'in:' . implode(',', $kinds), +		]); + +		if ($validator->fails()) { +			return [ +				'success' => false, +				'message' => $validator->errors()->first() +			]; +		} +  		$root = new Root;  		$root->root = $request->input('root'); -		$root->strong = 1; +		$root->root_kind_id = $request->input('root_kind_id');  		$root->save();  		return [ | 
