Assignment 5

For this assignment, create a new Laravel application called "assignment-5".

Create a configurations Table

In your database, create a table via a migration named configurations with columns id (primary key), name (string), and value (boolean). Be sure to add timestamp columns (created_at and updated_at) via the timestamps() method. These will be used when you update this table via Eloquent.

Insert a record into this table with name set to maintenance-mode and value set to false.

Maintenance Mode Middleware

You are going to create middleware that redirects users to a maintenance mode page (that you design yourself) at the URL path /maintenance if there is a record in the configurations table with a name of maintenance-mode and its value is true. If that record's value is false, users should be able to access the URL they requested. Create a test page at /test with anything you want on it with your middleware applied to it to verify everything works as expected.

If a user makes a request to /maintenance and the maintenance-mode setting is set false, the user should be redirected to /.

Name the middleware class MaintenanceMode.

A Settings Page

Create a secret page at /secret where you can toggle the value column of the record in the configurations table with a name of maintenance-mode using a checkbox. This page should not have the MaintenanceMode middleware applied to it.

Hint: Use $request->has() or $request->boolean() to determine if the checkbox is checked or not.

https://laravel.com/docs/12.x/requests#input-presence https://laravel.com/docs/12.x/requests#retrieving-boolean-input-values

Other Requirements

  • Use Eloquent for all database queries

Submission

Create a video with audio using Zoom where you demo your assignment and explain where you fulfilled or did not fulfill each requirement. Put a link to this recording in the README.md file at the root of your project.

https://classroom.github.com/a/DFJVxQ3u