snipe-it/app/Http/Requests/CustomFieldRequest.php

48 lines
847 B
PHP
Raw Normal View History

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
2017-11-06 16:42:37 -08:00
use Illuminate\Http\Request;
class CustomFieldRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
2017-11-06 16:42:37 -08:00
public function rules(Request $request)
{
2017-11-06 16:42:37 -08:00
$rules = [];
switch($this->method())
{
// Brand new
case 'POST':
{
$rules['name'] = "required|unique:custom_fields";
break;
}
default:break;
}
$rules['custom_format'] = 'valid_regex';
return $rules;
}
}