Laravel cant update data MYSQL
So I actually have this code everything shows up right in Doctor of Divinity however nothing modified within the table, will anyone recognize why? Ty for facilitate
$name = $request->get('name');
$now= new DateTime;
$userId = Auth::id();
dd($name . $userId); //tady je to ještě OK
DB::table('users')->where('id', $userId)->where('changed_name', '<', Carbon::now()->subdays(60)->toDateTimeString())->update(['name' => $name, 'changed_name' => $now]);
return redirect('/profile');
Seemi izaabel
Try using
$name = $request->get(‘name’);
$now= date(‘Y-m-d H:i:s’);
$userId = Auth::id();
dd($name . $userId); //tady je to ještě OK
DB::table(‘users’)->where(‘id’, $userId)->where(‘changed_name’, ‘update([‘name’ => $name, ‘changed_name’ => $now]);
OR
DB::table(‘users’)->where(‘id’, $userId)->where(‘changed_name’, ‘update([‘name’ => $name, ‘changed_name’ => $now]);
return redirect(‘/profile’);
avi
Be sure that name and changed_name are in $fillable array in user’s model.