I am programming the CRUD of the user (modified) in my laravel project (5.6) but when updating a user it conflicts with the registration / update dates, or at least that is what I have understood after reviewing several queries on the web.
Mi update:
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function update(Request $request)
{
$usuario = User::find($request['id']);
$usuario->id_role = $request['id_role'];
$usuario->name = $request['nom_usuario'];
$usuario->last_name = $request['ape_usuario'];
$usuario->rut_user = $request['rut_usuario'];
$usuario->telefono1 = $request['telefono1'];
$usuario->telefono2 = $request['telefono2'];
$usuario->email = $request['ema_usuario'];
$usuario->save();
return Redirect::to('/usuarios')->with('notice', 'El usuario ha sido modificado correctamente.');
}
My model:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function getListado(){
$usuarios = $this->join('roles', 'users.id_role', '=', 'roles.id_role')
->select('users.*', 'roles.des_role')
->orderBy('name', 'ASC');
return $usuarios;
}
}
When adding in the model the
public $ timestamps = false;
Saves but does not record the update date (which is the purpose of that statement) However, that also need to be saved, obviously.
I appreciate any contribution.
I have been resorting to this resource very often lately, I think it is the most healthy when we are learning a new tool and we can not find the indicated answer. I appreciate all the guidelines.