0
0
Laravelframework~30 mins

First Laravel application - Mini Project: Build & Apply

Choose your learning style9 modes available
First Laravel application
📖 Scenario: You want to create a simple Laravel web page that shows a welcome message. This is like setting up a new shop sign to greet visitors.
🎯 Goal: Build a basic Laravel application that displays a welcome message on the homepage using routes and views.
📋 What You'll Learn
Create a route for the homepage at '/'
Create a view file named welcome.blade.php in the resources/views folder
Pass a variable called message from the route to the view
Display the message variable inside the view
💡 Why This Matters
🌍 Real World
Creating routes and views is the foundation of building web pages in Laravel applications.
💼 Career
Understanding routing and Blade templating is essential for Laravel developers to build dynamic websites.
Progress0 / 4 steps
1
Set up the homepage route
In the routes/web.php file, create a route for the homepage at '/' that returns the view named 'welcome'.
Laravel
Need a hint?

Use Route::get('/', function () { return view('welcome'); }); to create the homepage route.

2
Create the welcome view file
Create a Blade view file named welcome.blade.php inside the resources/views folder. Inside it, write HTML with a heading that says Welcome to Laravel!.
Laravel
Need a hint?

Create a file welcome.blade.php with <h1>Welcome to Laravel!</h1> inside resources/views.

3
Pass a message variable from route to view
Modify the homepage route in routes/web.php to pass a variable called message with the value 'Hello from Laravel!' to the welcome view.
Laravel
Need a hint?

Use return view('welcome', ['message' => 'Hello from Laravel!']); inside the route.

4
Display the message variable in the view
In the welcome.blade.php file, add Blade syntax to display the message variable below the heading.
Laravel
Need a hint?

Use {{ $message }} in the Blade view to show the message variable.