The Customer table should have a user_id field. e.g. [id, user_id, name, firstname]
Then the Customer model automatically looks for User::id in relationship. see doc
Customer model relationship
public function user()
{
return $this->belongsTo('App\User');
}
User model relationship
public function customer() // <= not customer[s] for hasOne
{
return $this->hasOne('App\Customer');
}
If User::id and Customer::id are suppose to be related, You can specify keys without having a user_id field in the Customer table.
Customer model relationship
public function user()
{
return $this->belongsTo('App\User', 'id', 'id');
}
User model relationship
public function customer() // <= not customer[s] for hasOne
{
return $this->hasOne('App\Customer', 'id', 'id');
}