This assignment will continue to build off the same Laravel project you created previously.
The Tracks Page
Create a Tracks page located at /tracks
that shows a table of all tracks. Display the following fields:
- name
- album title
- artist name
- media type name
- genre name
- unit price
Add a link to the Tracks page in the main navigation.
Creating Tracks
Add a link with the text "New Track" at the top of the Tracks page. Clicking this link should take you to /tracks/new
. This page should display a form for creating a track. The form should contain:
- a text input for name
- a select menu populated with all available albums
- a select menu populated with all available media types
- a select menu populated with all available genres
- a number input for the unit price
When the user submits the form, the following should happen:
- Server-side validation with the following validation rules:
- All fields are required
- The album, media type, and genere selected must exist in the database.
- Unit price must be a number
- If the form is valid, the track is inserted into the database and the user is redirected back to the Tracks page with a success alert containing the text "The track TRACK NAME was successfully created", where TRACK NAME is replaced with the name of the newly created track.
- If the form is invalid, display error messages underneath the corresponding form controls. The form should also contain the user's invalid form data.
Renaming a Playlist
On the /playlists
page, display a link next to each playlist with the text "Rename". This link should take the user to /playlists/{id}/edit
where the user can change the name of the playlist. Display a text input on this page that is populated with the name of the playlist. The playlist name is required, should contain a maximum of 30 characters, and be unique (see the unique
validation rule). If validation fails, display an error message underneath the playlist name input and populate the input with what the user typed in. When a playlist is successfully renamed, redirect the user to /playlists
and display some kind of success alert on /playlists
with the text "X was successfully renamed to Y" (where X is the old playlist name and Y is the new playlist name) using Flashed Session Data.
Other Requirements
- Use Laravel's Blade templating. All pages should use a single layout that you define.
- All database queries should use Laravel's Query Builder
- All routes should map to a controller
- All routes should have a name and all URLs should use the
route()
helper function
Deleting a Playlist (optional)
On the /playlists
page, display a link next to each playlist with the text "Delete". Clicking the Delete link should take the user to a delete playlist confirmation page with the URL /playlists/{id}/delete
that says "Are you sure you want to delete PLAYLIST NAME?" where "PLAYLIST NAME" is replaced with the name of the playlist. There should be two buttons: Cancel and Delete. If the user clicks Cancel, they should be taken back to /playlists
. If the user clicks Delete, the playlist should be deleted and the user should be redirected to /playlists
. Make the delete happen through a POST request to /playlists/{id}/delete
via a form. Lastly, display some kind of success alert with the text "The X playlist was successfully deleted" where "X" is the name of the playlist that was deleted using Flashed Session Data.
Note, a playlist can't simply be deleted by deleting it from the playlists
table. The related records in playlist_track
need to be deleted too.
Submission
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 3". This should be the same URL that you submitted before. Sending us an email helps us keep track of assignment submissions.