Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Tutorial Laravel Tutorial 1: Intro to Routing filter_list
Author
Message
Laravel Tutorial 1: Intro to Routing #1
In the previous tutorial we installed Laravel and got it up and running. In this tutorial we will cover Routing in laravel. Don't forget to serve the application with php artisan serve when trying to visit the URL's.

What is Routing?
Routing is directing user requests to where they need to go. Laravel takes care of the Pretty URLs for us. Pretty URLs are a way to replace the querystring in the URL with something more eye pleasing. Instead of ?user=2f3rg&redir=1&something=else&here we would see something like /user/2ferg/redir/1/something/else/here.

Web Routes
The first thing we are going to do is edit the web routes file. It is located at routes/web.php

[Image: Screenshot-2022-06-02-3-07-21-PM.png]

The first route is the default route that is loaded by default. The next route was created by me. You can see the route the original code points to is called welcome. In the MVC architecture I know that there is probably a view named welcome. You can visit the URL http://localhost:8000/

Views
You can find your views folder in the resources folder. We can edit the welcome view by accessing it at resources/views/welcome.blade.php.

[Image: Screenshot-2022-06-02-3-13-27-PM.png]

I edited the links at the bottom of the page. I removed the links and made my own link that points to a view named user. Now we can copy the welcome.blade.php file into user.blade.php.

[Image: Screenshot-2022-06-02-3-17-03-PM.png]

Code:
cp resources/views/welcome.blade.php resources/views/user.blade.php

And edit the user.blade.php file to say something like User dashboard. And if you visit the URL http://localhost:8000/user you will see this:

[Image: Screenshot-2022-06-02-3-17-07-PM.png]
scarylerie.com

[+] 1 user Likes sunjester's post
Reply

RE: Laravel Tutorial 1: Intro to Routing #2
A very well documented and elaborated guide, that's easy to follow and understand.

Good work
[Image: AD83g1A.png]

Reply

RE: Laravel Tutorial 1: Intro to Routing #3
Good job keep them coming

Reply

RE: Laravel Tutorial 1: Intro to Routing #4
nice introduction to start it off
breached65xqh64s7xbkvqgg7bmj4nj7656hcb7x4g42x753r7zmejqd.onion/User-dior

Reply







Users browsing this thread: 1 Guest(s)