title: Laravel Invalid argument supplied for foreach
body: <p>Model Doctor</p>
  
  <pre><code>class Doctor extends Model
  {
      public function addresses() {
          return $this-&gt;belongsTo(Doctor::class);
      }
  }
  </code></pre>
  
  <p>Model Address</p>
  
  <pre><code> class Address extends Model
      {
        public function doctors() {
            return $this-&gt;hasMany(Address::class);
        }
      }
  </code></pre>
  
  <p>DoctorsController</p>
  
  <pre><code>class DoctorsController extends Controller
  {
      public function index()
      {
          $doctors = Doctor::with('addresses')-&gt;get();
  
          return view('doctors.index',compact('doctors'));
      }
  }
  </code></pre>
  
  <p>Blade</p>
  
  <pre><code>@foreach($doctors as $doctor)
      {{ $doctor-&gt;name }}
      @foreach($doctor-&gt;addresses as $address)
          {{ $address-&gt;city }}
      @endforeach
  
  @endforeach
  </code></pre>
  
  <p>I have an error</p>
  
  <blockquote>
    <p>Invalid argument supplied for foreach()</p>
  </blockquote>
  
  <p>I tried to make a relation between Doctor and Address, but it doesn't work. If i try dd($doctor->addresses) i have null.</p>