Added validation to tests creation and fixed a bug related to amount of wrong questions allowed in tests

This commit is contained in:
mwalbeck 2016-10-22 13:57:56 +02:00
parent b9ae12aa60
commit 7af12d0f5b
9 changed files with 287 additions and 142 deletions

View file

@ -0,0 +1,42 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class StoreTest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
if (Auth::user()->isAdministrator()) {
return true;
}
if (Auth::user()->isModerator()) {
return true;
}
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
"title" => "required|max:255|string",
"question_count" => "required|numeric",
"question_count_to_fail" => "numeric",
"time_limit" => "numeric",
"group_id" => "numeric"
];
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreUser extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}