Assignment 5

Rebuilding the Albums Module

Rebuild the Albums module exclusively using Eloquent. For the Albums page (/albums), be sure to eager load the artists to improve performance.

UPDATE: In order to sort by the related artist name, you can use a join like you did with the query builder. Below is an example.

$albums = Album::join('artists', '', '=', 'albums.artist_id')

Add a link to this version of the module in the main navigation with the text “Albums (Eloquent)“. Feel free to name your routes, controllers, and views however you wish. What will be graded for this assignment is that you got it working using Eloquent and had no DB calls.

If you’d like extra practice working with Eloquent, give the following challenges a try.

Extra Eloquent Practice (optional)

  • Recreate Assignment 2 with Eloquent. You should have a many-to-many relationship between the Playlist model and the Track model.
  • Recreate Assignment 3 with Eloquent.
  • Eloquent problems

    1. Find all tracks with the genre “Metal”.
    2. Find all customers who work for “Apple Inc.”.
    3. Find invoice 5 and update its BillingAddress to “123 Sesame Street”.
    4. What is the total of all invoices in 2012?
    5. What is the average track length?

For the last 2, check out the documentation on Retrieving Aggregates.


Verify that your app has been deployed to Heroku, which you set up in Assignment 2.

Send an email to Brighton and me with the URL to your GitHub repository with the subject: “ITP 405 - Assignment 5”. This should be the same URL that you submitted before. Sending us an email helps us keep track of assignment submissions.