Can't get Laravel associate to work
问题 I'm not quite sure if I understand the associate method in Laravel. I understand the idea, but I can't seem to get it to work. With this (distilled) code: class User { public function customer() { return $this->hasOne('Customer'); } } class Customer { public function user() { return $this->belongsTo('User'); } } $user = new User($data); $customer = new Customer($customerData); $user->customer()->associate($customer); I get a Call to undefined method Illuminate\Database\Query\Builder: