For this assignment, make a copy of your Assignment 2 repository by right clicking on your Assignment 2 folder, copying, and pasting (or some equivalent to that). Do not make a copy by going into the folder, selecting all files, copying them, and pasting into a new folder, as you may miss hidden files (hidden files are the ones that start with a period) which don't show up on a Mac in a Finder window. Rename the copy of Assignment 2 to Assignment 3. cd
into your Assignment 3 folder. Now, remove the origin
remote, as we'll be pointing this copy to another remote repository for your Assignment 3 GitHub Classroom repository.
git remote remove origin
The Tracks Page
Create a Tracks page located at /tracks
that shows a table of all tracks sorted by the track name using the orderBy method. Display the following fields:
- track 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" to the main navigation. 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 greater than 0
- 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 each of 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.
Deploy to Heroku / Zoom Recording
Deploy your Laravel app to Heroku and verify that it works. At the top of your project's README.md
, add your Heroku link.
Alternatively, create a Zoom recording where you walk us through all of the requirements of the assignment. Put this link at the top of your project's README.md
.
GitHub Classroom Submission
https://classroom.github.com/a/_Huekpew
Please read the section on Git, GitHub, and GitHub Classroom on the class welcome page if you need to refresh yourself.