Please, some help I'm trying a different ways to update an especific row. Im trying with models, I posted my first attempt. That is not good... The other option is to update each column, but, will be usefull has other ideas or options...
Route::put('/usuario/{fk_id_tid}/{ident}', function (Request $request, $fk_id_tid, $ident) {
$validator = Validator::make($request->all(), [
'ident' => 'required|digits_between:5,12',
'fname' => 'required|max:20',
'mname' => 'required|max:20',
'lname' => 'required|max:20',
'lname2' => 'required|max:20',
'email' => 'email',
'telefono' => 'min:7',
'celular' => 'min:10',
]);
if ($validator->fails()){
return redirect('/usuarios')
->withErrors($validator)
->withInput();
}
$user = DB::table('usuario')->where('fk_id_tid', $fk_id_tid)->where('ident', $ident)->first();
$user->fk_id_tid = $request->id_tid;
$user->ident = $request->ident;
$user->fname = $request->fname;
$user->mname = $request->mname;
$user->lname = $request->lname;
$user->lname2 = $request->lname2;
$user->email = $request->email;
$user->telefono = $request->telefono;
$user->celular = $request->celular;
$user->save();
return redirect('/usuarios');
});
the information of the columns comes with a post method.
Thanks for any help...