Add a Contact Page to Your Laravel Application

This is a free resource from my online course, From Idea To Launch, where I teach you how to build a full Laravel web application, step by step, at beginner's speed. Learn more →

You already created an About page, so you know how to create a full controller- and view-powered page in a Laravel application.

But we’re going to be doing a whole lot more of that throughout the rest of the course, so it’s a great thing to get some more practice with :)

In this exercise, you’re going to add a new Contact page to accompany your (currently lonely) About page.

1. Add a new route for the Contact page

You know the drill.

In the routes config file — app/Http/routes.php — create a new route for the Contact page, so that when you can access the URL http://fitl.local/contact, it points to the PageController‘s contact action (which you’ll create next).

2. Create the contact action

In your PageController, add a new contact action — remember, a controller action is just a function in a controller whose explicit purpose is to fulfill a user request.

In that action, write code to load up a new contact view, remembering that this new view will live in the pages subdirectory of the main views folder.

Now you just need to create the new view.

3. Create the contact view

Create your new contact view file in the resources/views/pages folder within your application.

Add some basic HTML to that new view file, including, for example, your name, email address, and links to your social media.

Don’t worry too much about the page’s appearance right now; we’ll be sprucing up the entire app’s appearance in a later lesson.

Time to test it out! You should be able to access your new Contact page at the following URL:



Another controller- and view-powered application page in the bag. Nice work :)