dsfvsdfv23599 2016-03-13 20:11
浏览 47
已采纳

Laravel AuthController不更新功能体

For a school project I am trying to remove Eloquent from the core of my project (have to work directly with DB, cannot use ORM).

I am now trying to modify the create function of the AuthController, but it does not seem to be updating. (Using XAMPP with PHP7.)

As you can see I tried to replace the User::create default with the DB::insert statement inside of AuthController's create function.

protected function create(array $data)
{
  return DB::insert('INSERT INTO users (firstname,lastname,birthday,gender,email,password) values(?,?,?,?,?,?)',
    array(
      $data['firstname'],
     $data['lastname'],
     $data['birthday'],
     $data['gender'],
     $data['email'],
     bcrypt($data['password'])
    )
  );

    // OLD FUNCTION BODY:
    /*return User::create([
        'firstname' => $data['firstname'],
        'lastname' => $data['lastname'],
        'birthday' => $data['birthday'],
        'gender' => $data['gender'],
        'email' => $data['email'],
        'password' => bcrypt($data['password'])
    ]);*/
}

But now I keep getting:

FatalThrowableError in AuthController.php line 71: Fatal error: Call to undefined method App\User::create()

I believe that the function needs more than DB::insert, as it says, that it should return a new instance of the User object, but at the moment I cannot even test what this would do as it is still trying to call the old function body. I have even deleted the User::create section alltogether.

Is this a XAMP thing? I had no problem updating and saving other files of this project, but this controller does not make it through it seems like.

  • 写回答

2条回答 默认 最新

  • drbii0359 2016-03-14 04:23
    关注

    Try to clean Laravel cache. Then use this:

    return DB::insert(array(
         'firstname' => $data['firstname'],
         'lastname' => $data['lastname'],
         'birthday' => $data['birthday'],
         'gender' => $data['gender'],
         'email' => $data['email'],
         'password' => bcrypt($data['password'])
        )
      );
    

    If you will still get the error, please post contents of 71th line of AuthController.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致