I'm trying to mail a verification code to a user. In order to do that I've to declare a variable in array like this,
$data = array(
'code' => rand(1000, 9999)
);
And then I want to save it to the DB:
$user->code = $data['code'];
$user->save();
But it gives an error:
undefined offset 0 or Creating default object from empty value.
What should I do?
via ishan shah