Call to undefined method Illuminate\Database\Query\Builder::associate()

后端 未结 4 832
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 11:29

Reference: How can I update an existing Eloquent relationship in Laravel 4?

$userinfo = \\Userinfo::find($id);
\\User::find($id)->userinfo()->associate         


        
4条回答
  •  被撕碎了的回忆
    2021-01-01 12:18

    You need to specify the field related like this:

        public function profile()
        {
            return $this->hasOne('App\AdmProfile', 'id');
        }
    

提交回复
热议问题