dpnru86024 2014-09-05 20:43
浏览 11
已采纳

Laravel 4与阵列的关系

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');      
    }
  • 写回答

1条回答 默认 最新

  • 普通网友 2014-09-05 21:12
    关注

    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
            ));
    

    ?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作