简体   繁体   English

Laravel 4数组关系

[英]Laravel 4 relations from array

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. 我试图通过与变量建立关系来获取数组中的字段,并且出现“未定义的属性:Illuminate \\ Database \\ Eloquent \\ Builder :: $ email”错误,任何帮助都将非常感谢。 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. 问题在于$Passed->email给您该错误,因为$Passed不是模型或集合,而是查询构建器,可能是因为insert模型不能完成插入记录并返回的全部工作新模型。 So, shouldn't it be: 因此,应该不是:

$Passed = User::create(array(
        'email' => $email,
        'username' => $username,
        'password' => Hash::make($password),
        'code' => $code,
        'active' => 0,
        'groups' => 0
        ));

?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM