title: Is there a way to access relationship attributes as own in laravel model?
body: <p>I have 2 tables: <strong><em>users</em></strong> and <strong><em>users_details</em></strong></p>
  
  <p>-- users has 3 columns [id,username,password]</p>
  
  <p>-- users_details has [id,user_id,name,address]</p>
  
  <p>I have models for each of them with a relation from users to users_details.</p>
  
  <pre><code>    public function details()
      {
          return $this-&gt;hasOne(UserDetails::class, 'user_id', 'id');
      }
  </code></pre>
  
  <p>my question comes here: Is there a way to access UsersDetails attributes as User only.</p>
  
  <p>e.g: <strong>{{ $user->name }} : {{ $user->address }}</strong>
  instead of <strong>{{ $user->details->name }} : {{ $user->details->address }}</strong></p>
  
  <p>Keep in mind that these tables are only examples and don't have their real range of columns. I need this to implement Laravel/Cashier but this plugin needs 4 new columns in [users] table and I want to put them in [users_details] table.</p>
  
  <p>I haven't tried anything because I don't really know if it is possible. Except for the moment the only workaround that I know of is to make getNameAttribute method in User:</p>
  
  <pre><code>    public function getNameAttribute()
      {
          return $this-&gt;details-&gt;name;
      }
  </code></pre>