Added validation to tests creation and fixed a bug related to amount of wrong questions allowed in tests
This commit is contained in:
parent
b9ae12aa60
commit
7af12d0f5b
9 changed files with 287 additions and 142 deletions
app/Http/Requests
42
app/Http/Requests/StoreTest.php
Normal file
42
app/Http/Requests/StoreTest.php
Normal 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"
|
||||
];
|
||||
}
|
||||
}
|
30
app/Http/Requests/StoreUser.php
Normal file
30
app/Http/Requests/StoreUser.php
Normal 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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
Reference in a new issue