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

    ?

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

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?