title: Join query in laravel with data manipulation send to view
body: <p>I am having 2 tables, <code>users</code> and <code>profiledetails</code> </p>
  
  <p>I am able to run Join query and access the data and send to view.</p>
  
  <p>But when I am manipulation the field 'dob' (date format) in <code>profiledetails</code> table. No Success, Please check the code below , </p>
  
  <p><code>webpagesConroller</code>:</p>
  
  <pre><code>$users = DB::table('users')
          -&gt;join('profiledetails', 'users.id', '=', 'profiledetails.user_id')  
          -&gt;select('users.*', 'profiledetails.dob')
          -&gt;get();
      $age = $users-&gt;dob-&gt;diffInYears(Carbon::now());         
      return view('webpages.index',compact('users'))-&gt;with($age);
  </code></pre>
  
  <p><code>View:</code></p>
  
  <pre><code>&lt;li class="cate_head"&gt;Age : {{ $age}}&lt;/li&gt;
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Trying to get property of non-object
  </code></pre>
  
  <p>I have model <code>Profiledetails</code> added the mutators as below,</p>
  
  <pre><code>  public function getAge(){
  
         return $this-&gt;dob-&gt;diffInYears(Carbon::now());            
  
      }
  
      public function getDOB(){
          return $this-&gt;dob-&gt;format('d-m-Y');
      }
  </code></pre>
  
  <p>Can I not use this method on another controller for Ex- webpagesController, If yes How.</p>