title: Is it possible to get data of related model inside current model in Laravel?
body: <p>I'm building the Laravel app which using recursive url constructing. And I want to know is it possible to access data of the hasone related model within model to return constructed url direct to the view without interacting by controller.\</p>
  
  <pre><code>public function link(){
      var_dump($this-&gt;category());
      $url = ['news'];
      $url[] = $this-&gt;category()-&gt;url;
      $url[] = $this-&gt;url;
      return implode('/',$url);
  }
  </code></pre>
  
  <p>Simple code example like this return this one</p>
  
  <pre><code>Undefined property: Illuminate\Database\Eloquent\Relations\HasOne::$url (View: /???/resources/views/common/news/full_preview.blade.php) (View: /???/resources/views/common/news/full_preview.blade.php) (View: /???/resources/views/common/news/full_preview.blade.php)
  </code></pre>
  
  <p>So is there any good way solve it by using just eloquent models, or it's only possible by using controllers and so on?</p>