Q:

Call to a member function create() on null

I know this is the same quetion title like others, but i cant find the right answer for me. Here is my problem.
I am trying to insert data to the other table after users data inserted. But what i got is Call to a member function create() on null.
Here is my code of AuthController.php
protected function create(array $data)
{
    $user = User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
    ]);

    $user->usersbasics()->create([
        'user_id' => $user->id,
    ]);

    return $user;
}

Here is my User model
public function usersbasics()
{
    $this->hasOne('App\UsersBasics');
}

Here is my UsersBasics model:
public function user()
{
    $this->belongsTo('App\User');
}

I tried var_dumb($user->usersbasics()) and the result is NULL.
What is whrong with my code? because i use the same for my other work, and its fine. Please someone explain me and give me a solution. Please..
thank you,

A:

This is a late answer, but I ran into the same problem.
You don't have the return keyword on both your relationships. 
public function user()
{
    return $this->belongsTo('App\User');
}

and 
public function usersbasics()
{
  return  $this->hasOne('App\UsersBasics');
}

This fixxed it for me.

