So I am extending the AuthController
to contain a few more fields, which are all working great apart from a link to the users avatar (it is an URL of around 150 chars long). Code looks like:
return User::create([
'first_name' => ucfirst($first_name),
'last_name' => ucwords($last_name),
'email' => $data['email'],
'password' => bcrypt($data['password']),
'dob' => date("Y-m-d", strtotime($dob)),
'avatar' => $data['avatar'],
'gender' => $data['gender'],
]);
The URL is being sent using a hidden field and I can confirm it is being sent by looking at POST
data on firefox.
When I am looking at the MySQL log, I can see the insert for the rest of the fields, but for some reason, it is skipping or missing out the avatar
field altogether. MySQL log shows:
Prepare insert into `users`
(`name`, `email`, `password`, `dob`, `gender`, `updated_at`, `created_at`)
values (?, ?, ?, ?, ?, ?, ?)
it should be:
Prepare insert into `users`
(`name`, `email`, `password`, `dob`, `gender`, `avatar`, `updated_at`, `created_at`)
values (?, ?, ?, ?, ?, ?, ?, ?)
I have also added validation rule:
'avatar' => 'sometimes|url|max:255,
Although I do not think validation is the issue as it does not work even if this is commented out..
I don't think I need to do mysqli_real_escape_string as it is PDO? Also it's not a cache issue as I have changed and tested other fields and they work fine.
Does anyone have any other ideas?
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire