mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Fixed form request ffor custom fields
This commit is contained in:
parent
6ece593629
commit
dc32e4bdb0
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class CustomFieldRequest extends FormRequest
|
class CustomFieldRequest extends FormRequest
|
||||||
{
|
{
|
||||||
|
@ -21,11 +22,26 @@ class CustomFieldRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules(Request $request)
|
||||||
{
|
{
|
||||||
return [
|
|
||||||
"name" => "required|unique:custom_fields",
|
$rules = [];
|
||||||
"custom_format" => "valid_regex",
|
|
||||||
];
|
switch($this->method())
|
||||||
|
{
|
||||||
|
|
||||||
|
// Brand new
|
||||||
|
case 'POST':
|
||||||
|
{
|
||||||
|
$rules['name'] = "required|unique:custom_fields";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rules['custom_format'] = 'valid_regex';
|
||||||
|
|
||||||
|
return $rules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue