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', 'artists.id', '=', 'albums.artist_id') ->orderBy('artists.name') ->get();
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
If you’d like extra practice working with Eloquent, give the following challenges a try.
- Recreate Assignment 2 with Eloquent. You should have a many-to-many relationship between the
Playlistmodel and the
- Recreate Assignment 3 with Eloquent.
- Find all tracks with the genre “Metal”.
- Find all customers who work for “Apple Inc.”.
- Find invoice 5 and update its
BillingAddressto “123 Sesame Street”.
- What is the total of all invoices in 2012?
- 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.