I'm trying to grab a field in a array by making a relation to the variable and i am getting the error of "Undefined property: Illuminate\Database\Eloquent\Builder::$email", Any help would be great and many thanks. my Controller is below.
else {
$email = Input::get('email');
$username = Input::get('Username');
$password = Input::get('password');
$code = str_random(60);
$Passed = User::Insert(array(
'email' => $email,
'username' => $username,
'password' => Hash::make($password),
'code' => $code,
'active' => 0,
'groups' => 0
));
Mail::send('emails.auth.Email',array(
'link' => URL::route('account-activate', $code),
'Username' => $username),
function($message) use ($Passed) {
$message->to($Passed->email, $Passed->username)->subject('activation');
});
return Redirect::route('home')->with('global', 'Hello world');
}
The problem is that $Passed->email
is giving you that error, because $Passed
is not a model or a collection, but still a query builder, probably because the insert model doesn't do the whole job of inserting the record and returning the new model. So, shouldn't it be:
$Passed = User::create(array(
'email' => $email,
'username' => $username,
'password' => Hash::make($password),
'code' => $code,
'active' => 0,
'groups' => 0
));
?