title: Laravel 5.6.17 Model hasOne over multiple tables
body: <p>I'm quite new to Laravel and now I'm trying to move parts of a former application from a small self written framework into Laravel. The address book is multilingual therefor the table structure is a little more complicated.</p>
  
  <p><a href="https://i.stack.imgur.com/HXL0N.png" rel="nofollow noreferrer">db-structure</a></p>
  
  <p>And this is my source code:</p>
  
  <ul>
  <li>AddressBookController.php </li>
  </ul>
  
  
  
  <pre class="lang-php prettyprint-override"><code>        namespace App\Http\Controllers;
  
          use App\AddressBook as AB;
          use Illuminate\Http\Request;
          use Illuminate\Support\Facades\Validator;
  
          class AddressBookController extends Controller
          {
              /**
               * Display a listing of the resource.
               *
               * @return \Illuminate\Http\Response
               */
              public function index()
              {
                  $entries = AB::all();
  
                  return view('addressBook')-&gt;with([
                      'class' =&gt; __CLASS__,
                      'function' =&gt; __FUNCTION__,
                      'line' =&gt; __LINE__,
                      'entries' =&gt; $entries,
                  ]);
              }
          }
  </code></pre>
  
  <ul>
  <li><p>Model AddressBook.php</p>
  
  <pre class="lang-php prettyprint-override"><code>    namespace App;
  
      use Illuminate\Database\Eloquent\Model;
  
  
      class AddressBook extends Model
      {
          protected $table = 'address';
          protected $primaryKey = 'address_id';
          protected $keyType = 'int';
          public $incrementing = true;
          public $timestamps = false;
          protected $searchable = [
              'columns' =&gt; [
                  'address.address_surname' =&gt; 10,
                  'address.address_company' =&gt; 5,
                  'address.address_vatid' =&gt; 2,
              ],
          ];
  
          public function country() {
              return $this-&gt;hasOne('country', 'country_id', 'country_id');
          }
  
          public function addresstype() {
              return $this-&gt;hasOne('addresstype', 'addresstype_id', 'addresstype_id');
          }
      }
  </code></pre></li>
  <li><p>Model Country.php</p>
  
  <pre class="lang-php prettyprint-override"><code>    namespace App;
  
      use Illuminate\Database\Eloquent\Model;
  
      class Country extends Model
      {
          protected $table = 'country';
          protected $primaryKey = 'country_id';
          protected $keyType = 'int';
          public $incrementing = true;
          public $timestamps = false;
  
          public function translation() {
              return $this-&gt;hasOne('translations', 'translations_id', 'translations_id');
          }
  
          public function addressbook() {
              return $this-&gt;belongsTo('address', 'country_id', 'country_id');
          }
      }
  </code></pre></li>
  <li><p>Model AddressType</p>
  
  <pre class="lang-php prettyprint-override"><code>    namespace App;
  
      use Illuminate\Database\Eloquent\Model;
  
      class AddressType extends Model
      {
          protected $table = 'addresstype';
          protected $primaryKey = 'addresstype_id';
          protected $keyType = 'int';
          public $incrementing = true;
          public $timestamps = false;
  
          public function translation() {
              return $this-&gt;hasOne('translations', 'translations_id', 'translations_id');
          }
  
          public function addressbook() {
              return $this-&gt;belongsTo('address', 'addresstype_id', 'addresstype_id');
          }
      }
  </code></pre></li>
  <li><p>Model Translation.php</p>
  
  <pre class="lang-php prettyprint-override"><code>    namespace App;
  
      use Illuminate\Database\Eloquent\Model;
  
      class Translation extends Model
      {
          protected $table = 'translations';
          protected $primaryKey = 'translations_id';
          protected $keyType = 'int';
          public $incrementing = true;
          public $timestamps = false;
  
          public function country() {
              return $this-&gt;belongsTo('country', 'translations_id', 'translations_id');
          }
  
          public function addresstype() {
              return $this-&gt;belongsTo('addresstype', 'translations_id', 'translations_id');
          }
      }
  </code></pre></li>
  </ul>
  
  <p>The request "$entries = AB::all();" works in general but I get the id's and maybe I'm completely wrong here but I thought that data from foreign keys will be replaced with the respective models (if configured correctly). so my question is:</p>
  
  <p>a. did I make a mistake during configuration and if yes, where exactly is the error?<br>
  or<br>
  b. is my assumption of replacing id's with objects is completly wrong?</p>
  
  <p>Thanks in advance!
  Steve</p>