title: How to apply diffForHumans() in laravel using ajax?
body: <p>I'm working with laravel and native ajax. I am wondering where do I put diffForhHumans() when using ajax. In my Controller. I just return the object fetch.</p>
  
  <p>Here's my Controller</p>
  
  <pre><code>public function getDownlines($id) {
      $upline = Upline::find($id);
  
      return $upline-&gt;downlines;
  }
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>public function downlines() {
      return $this-&gt;hasMany('App\Downline');
  }
  </code></pre>
  
  <p>HTML Code in View</p>
  
  <pre><code>&lt;div id="downlines"&gt;
      &lt;div class="downlines-title-container"&gt;
          &lt;p class="title"&gt;&lt;/p&gt;
      &lt;/div&gt;
  
      &lt;div id="downlines-holder"&gt;
          &lt;div class="p_parent_header"&gt;
              &lt;p&gt;ID&lt;/p&gt;
              &lt;p&gt;Account Code&lt;/p&gt;
              &lt;p&gt;Created By&lt;/p&gt;
              &lt;p&gt;Created At&lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Script in Ajax</p>
  
  <pre><code>var downlines = document.getElementById('downlines'),
      downlines_holder = document.getElementById('downlines-holder');
  
  function getPromise(url) {
      return new Promise(function(resolve, reject) {
          var xhr = new XMLHttpRequest();
  
          xhr.open('GET', url);
  
          xhr.onload = function() {
              if(xhr.status == 200) {
                  resolve(xhr.response);
              } else {
                  reject(Error(xhr.statusText))
              }
          }
  
          xhr.onerror = function() {
              reject(Error('Network Error'));
          };
  
          xhr.send();
      })
  }
  
  function getDownlines(e, id) {
      getPromise('upline/getdownlines/' + id).then(function(response) {
          var resp = JSON.parse(response),
              p_parent = document.getElementsByClassName('p_parent'),
              p = p_parent.length;
  
              while(p--) p_parent[p].remove();
  
          if(resp.length &gt; 0) {
              downlines.style.display = 'initial'
              downlines.children[0].children[0].innerHTML = e.innerHTML;
  
              for(var i = 0; i &lt; resp.length; i++) {
                  var p_parent = document.createElement('div'),
                      p1 = document.createElement('p'),
                      p2 = document.createElement('p'),
                      p3 = document.createElement('p'),
                      p4 = document.createElement('p');
  
                  p_parent.classList.add('p_parent');
                  p1.innerHTML = resp[i].id;
                  p2.innerHTML = resp[i].account_code;
                  p3.innerHTML = resp[i].created_by;
                  p4.innerHTML = resp[i].updated_at;
                  p_parent.appendChild(p1);
                  p_parent.appendChild(p2);
                  p_parent.appendChild(p3);
                  p_parent.appendChild(p4);
                  downlines_holder.appendChild(p_parent);
              }
          } else {
              downlines.style.display = 'none'
          }
      }, function(error) {
          console.log(error);
      })
  }
  </code></pre>
  
  <p>I'm searching for the same problem and doesn't find one.</p>
  
  <p>Any help would be appreciated. Thanks!!!</p>