For this assignment, scaffold a new Laravel application called "assignment-8".
On a page at the URL /stats
, add a button with the text "Email Stats to Users". This should be a form with a single button that makes a POST request to /stats
. This endpoint should send an HTML email using a Blade template to all users with the following stats:
- Total number of artists
- Total number of playlists
- The sum of
milliseconds
for all tracks displayed in minutes. Round to the nearest minute.
One approach to generating stats is writing aggregate queries.
Feel free to style it however you wish. A Bootstrap Card might be a good choice.
Other Requirements
- Emails should be queued.
- You must use a job class.
- You must use a mailable class.
Restarting the Queue Worker
Running php artisan queue:work
will run a queue worker, which is a long-lived processes and stores the booted application state in memory. As a result, it will not notice changes in your code base after it has been started. If you make changes to code, simply restart this command. Read Running The Queue Worker from the Laravel documentation for more details.
Submission
Unfortunately, the topics we covered this week won't work on Heroku. Sending a real email involves paying for an email service like Mailgun, which I won't ask you to do.
Furthermore, we would need a process that keeps php artisan queue:work
running permanently in the background, which I'm almost certain doesn't work on Heroku with the free plan. Laravel Forge is a service very similar to Heroku but made for Laravel apps and it makes this easy. I highly recommend this if you ever want to deploy a Laravel project. However, this roughly costs $20/month, which I won't ask you to pay for either.
So, to turn this assignment in, create a short video using Zoom where you demo your application. Be sure to have at least 2 users in your users
table. Put your Zoom link in your README.md file.
https://classroom.github.com/a/H8PvrTCL
Please read the section on Git, GitHub, and GitHub Classroom on the class welcome page if you need to refresh yourself.