title: How to make a query to filter with a pivot table & another table in Laravel 5?
body: <p>Sorry for the title I really don't know what to call it.</p>
  
  <p>I am building a illustration website with albums.
  A illustration can be uploaded to a album.</p>
  
  <p>In the photos table I have a processed table in it.
  This way I can check if the illustration was processed or not, if yes then it can be searchable if not then the user must edit the processed illustration or illustrations.</p>
  
  <p>I can select the photos in the specific album but I don't know how to filter with the processed illustration belonging to the viewing album.</p>
  
  <p>Also I have  a seperate table album_photos table.
  The relation of a album and a photo is hasMany and belongsToMany.</p>
  
  <p>This way I select all the photos but not filtered with processed or not.</p>
  
  <pre><code>$photos = Photo::whereIn('id', $album -&gt; album_photos() -&gt; pluck('photo_id'))-&gt;get();
  </code></pre>
  
  <p>And this way I select all the processed photos of the corresponding user.</p>
  
  <pre><code>$photosNotProcessed = Photo::where('user_id', Auth::user() -&gt; id)-&gt;whereNull('processed')-&gt;get();
  </code></pre>
  
  <p>Now I want to select the photos in the viewing album that is not been processed.
  Any ideas?</p>
  
  <p>Thanks in advance.</p>