title: How to output 'Favourites/Likes' list in Laravel 5.3?
body: <p>I have implemented a like/favourite function in my application, where a user can favourite a Charity - this is then stored in a table in my database - which is working reasonably well.</p>
  
  <p>How would I go about outputting the users favourites list to them on their profile page?</p>
  
  <p>Profile View (Where I want to output):</p>
  
  <pre><code>&lt;div class="favourite_section"&gt;
  
  &lt;div class="col-md-5 pull-right"&gt;
  
    &lt;div class="panel panel-default"&gt;
  
      &lt;div class="panel-heading"&gt;
  
        &lt;a href="#" class="pull-right"&gt; Edit &lt;/a&gt;
  
          &lt;h3 class="panel-title"&gt; Your Favourites &lt;/h3&gt;
  
       &lt;/div&gt;
  
        &lt;div class="panel-body"&gt;
  
          &lt;!-- Output users' favourites. --&gt;
  
            &lt;h4&gt;  &lt;/h4&gt;
  
        &lt;/div&gt;
  
    &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>Like Controller:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  use App\Like;
  use Illuminate\Support\Facades\Auth;
  
  class LikeController extends Controller
  {
  public function likePost($id)
  {
      $this-&gt;handleLike('App\charity', $id);
      return redirect()-&gt;back();
  }
  
  public function handleLike($type, $id)
  {
      $existing_like = Like::withTrashed()-&gt;whereCharityImg($type)-&gt;whereCharityDesc($type)-&gt;whereCharityName($type)-&gt;whereCharityId($id)-&gt;whereUserId(Auth::id())-&gt;whereId($id)-&gt;first();
      if (is_null($existing_like))
      {
          Like::create([
              'id'       =&gt; $id,
              'user_id'   =&gt; Auth::id(),
              'charity_id' =&gt; $id,
              'charity_name' =&gt; $type,
              'charity_desc' =&gt; $type,
              'charity_img' =&gt; $type
          ]);
  
      } 
      else
      {
          if (is_null($existing_like-&gt;deleted_at))
          {
              $existing_like-&gt;delete();
          }
  
          else
          {
              $existing_like-&gt;restore();
          }
      }
  }
  }
  </code></pre>