Carga inicial
This commit is contained in:
50
app/Http/Requests/Administrador/ServiciosRequest.php
Normal file
50
app/Http/Requests/Administrador/ServiciosRequest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Administrador;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ServiciosRequest 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
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
if($this->method()=='PUT'){
|
||||
|
||||
$params = $this->route()->parameters();
|
||||
$id = $params['servicio'];
|
||||
|
||||
return [
|
||||
'nombre' => 'string|required|min:1|max:191|unique:cat_servicios,nombre,'.$id.',id',
|
||||
];
|
||||
|
||||
}else{
|
||||
|
||||
return [
|
||||
'nombre' => 'string|required|min:1|max:191|unique:cat_servicios,nombre',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$messages = [
|
||||
'nombre.unique' => 'El nombre que ingresó ya se encuentra en nuestros registros.'
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user