我试图通过建立与变量的关系来获取数组中的字段,并且我得到的错误是" Undefined属性:Illuminate \ Database \ Eloquent \ Builder :: $ email&#34 ;, 任何帮助都会很棒,非常感谢。我的控制器在下面。
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');
}
答案 0 :(得分:0)
问题是$Passed->email
给出了这个错误,因为$Passed
不是模型或集合,但仍然是查询构建器,可能是因为插入模型不能完成整个工作插入记录并返回新模型。所以,不应该是:
$Passed = User::create(array(
'email' => $email,
'username' => $username,
'password' => Hash::make($password),
'code' => $code,
'active' => 0,
'groups' => 0
));