title: Trying to get property of non-object error with laravel blade foreach
body: <p>Hi I have a <code>Trying to get property of non-object</code> error which I just can't seem to solve. In my view I have a <code>@foreach</code>, using relationship tables. The relationships seems to be fine when I check them. The are also no null values in my banks table. I have a user principles table, banks table that I used as relationships to the banking accounts table. With the user principles I do not use a <code>@foreach</code> and data displays <code>{{ $bankAcc-&gt;userprinciple-&gt;principle }}</code> correctly.</p>
  
  <p>Here is my Bank Account Model (the relationship with banks):</p>
  
  <pre><code>public function banks(){
      return $this-&gt;belongsTo('App\Models\Banks', 'bank_detail_id');
  }
  </code></pre>
  
  <p>Here is my Controller:</p>
  
  <pre><code>public function edit($id){
      $bankAcc = BankingAccount::where('id', $id)-&gt;with('userprinciple')-&gt;with('banks')-&gt;first();
      return view('admin.administration.banking.accounts.edit', compact('bankAcc'));
  }
  </code></pre>
  
  <p>My view: </p>
  
  <pre><code>&lt;select class="form-control" name="name_of_bank"&gt;
      @foreach($bankAcc-&gt;banks as $bankA)
          &lt;option value="{{ $bankA-&gt;id }}"&gt;{{ $bankA-&gt;name }}&lt;/option&gt;
      @endforeach
  &lt;/select&gt;
  </code></pre>