title: Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::associate()
body: <p>I am trying to create a relationship in Laravel. I want to add data using one to one and one to many relationship and save the data to database. I'm stuck with this is error : </p>
  
  <pre><code>Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::associate()
  </code></pre>
  
  <p>StudentsController.php</p>
  
  <pre><code>public function store(Request $request)
      {
          $this-&gt;validate(
          $request,
          [
            'nama' =&gt; 'required',
            'nim' =&gt; 'required|size:10',
            'tanggal_lahir' =&gt; 'required',
            'jenis_kelamin' =&gt; 'required',
            'class_student_id' =&gt; 'required',
            'telephone' =&gt; 'nullable|numeric|digits_between:10,15|unique:telephones,telp_number'
          ],
          [
            'nama.required' =&gt; 'Form nama lengkap tidak boleh kosong',
            'nim.required' =&gt; 'Form nomor induk siswa tidak boleh kosong',
            'nim.size' =&gt; 'Form nomor induk siswa membutuhkan 10 karakter',
            'tanggal_lahir.required' =&gt; 'Form tanggal lahir tidak boleh kosong',
            'jenis_kelamin.required' =&gt; 'Form jenis kelamin tidak boleh kosong',
            'class_student_id.required' =&gt; 'Form kelas tidak boleh kosong'
          ],
        );
  
        $student = Student::create($request-&gt;all());
  
        $class_student = new ClassStudent;
        $class_student-&gt;student()-&gt;associate($student);
        $class_student-&gt;save();
  
        $telephone = new Telephone([
          'telp_number' =&gt; $request-&gt;input('telephone')
        ]);
        $student-&gt;telephone()-&gt;push($telephone);
  
        return redirect('students')-&gt;with('status', 'Data siswa berhasil ditambahkan');
      }
  </code></pre>
  
  <p>Student.php</p>
  
  <pre><code>class Student extends Model
  {
      protected $fillable = [
        'nim',
        'nama',
        'tanggal_lahir',
        'jenis_kelamin',
        'class_student_id'
      ];
  
      public function telephone()
      {
        return $this-&gt;hasOne(Telephone::class);
      }
  
      public function classStudent()
      {
          // return $this-&gt;belongsTo(ClassStudent::class);
          return $this-&gt;belongsTo('App\ClassStudent', 'class_student_id');
      }
  }
  </code></pre>
  
  <p>Telephone.php</p>
  
  <pre><code>class Telephone extends Model
  {
    protected $fillable = ['id', 'telp_number'];
  
    public function student()
    {
        return $this-&gt;belongsTo(Student::class);
    }
  }
  </code></pre>
  
  <p>ClassStudent.php</p>
  
  <pre><code>class ClassStudent extends Model
  {
      protected $fillable = ['id', 'class_name'];
  
      public function student()
      {
          // return $this-&gt;hasMany(Student::class);
          return $this-&gt;hasMany('App\Student', 'id');
      }
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>