validacion con request
This commit is contained in:
parent
9d9b6c5be9
commit
ac8dfe04b3
|
|
@ -46,7 +46,7 @@ class CategoriasController extends Controller
|
||||||
|
|
||||||
public function store(Request $request){
|
public function store(Request $request){
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'descripcion' => 'required|max:20',
|
'descripcion' => 'required|max:20',
|
||||||
'nombre' => 'required|unique:categorias,nombre|regex:/^[a-zA-ZáéíóúñÁÉÍÓÚ]+( [a-zA-ZáéíóúñÁÉÍÓÚ]+)*$/|max:20',
|
'nombre' => 'required|unique:categorias,nombre|regex:/^[a-zA-ZáéíóúñÁÉÍÓÚ]+( [a-zA-ZáéíóúñÁÉÍÓÚ]+)*$/|max:20',
|
||||||
//'dni' => 'required|numeric|digits_between:7,8',
|
//'dni' => 'required|numeric|digits_between:7,8',
|
||||||
|
|
@ -62,7 +62,6 @@ class CategoriasController extends Controller
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$categorias = new Categorias();
|
$categorias = new Categorias();
|
||||||
$categorias->fill([
|
$categorias->fill([
|
||||||
'nombre' => $request->input('nombre'),
|
'nombre' => $request->input('nombre'),
|
||||||
|
|
@ -79,7 +78,7 @@ class CategoriasController extends Controller
|
||||||
return view('categorias.edit', ["cat"=>$categoria]);
|
return view('categorias.edit', ["cat"=>$categoria]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, $id){
|
public function update(UpdatedCategoriaRequest $request, $id){
|
||||||
$categorias = Categorias::findOrfail($id);
|
$categorias = Categorias::findOrfail($id);
|
||||||
$categorias->fill([
|
$categorias->fill([
|
||||||
'nombre' => $request->input('nombre'),
|
'nombre' => $request->input('nombre'),
|
||||||
|
|
|
||||||
28
app/Http/Requests/StoreCategoriasRequest.php
Normal file
28
app/Http/Requests/StoreCategoriasRequest.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreCategoriasRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -37,7 +37,6 @@
|
||||||
name="nombre"
|
name="nombre"
|
||||||
id="nombre"
|
id="nombre"
|
||||||
value="{{ old('nombre') }}"
|
value="{{ old('nombre') }}"
|
||||||
required
|
|
||||||
class="form-control">
|
class="form-control">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user