Thứ Sáu, 28 tháng 12, 2018

Auto news on Youtube Dec 28 2018

It's time for us to start exploring routes.

Start the project

goto the directory

start visual studio code

we are here and

this is routes folder

open this folder

there is a file web

web.php

open this file and

lets go to the browser.

Whatever we write here

just like this

slash c and slash

This is called route.

What you see in address bar in browser

is route in Laravel.

OK

and this is the route file

this is saying that

route method is

GET

there are various methods

you know that

like post, put, delete

so this is home URL

what will this do

this will return a view

the name of file is welcome

so lets see where it is

the view folder is in

here resources, views

open the views folder

you will see a welcome

(dot) blade (dot) php file

lets see whats inside

this welcome.blade file

this is our welcome.blade.php

so this route is actually

returning this view

returning this view

lets check it

start terminal

and

lets write

php artisan serve

so we have this

copy this

here is our page.

This is what welcome.blade.php exactly is

lets assume that we want to

show our contact information

what will we do?

we will duplicate these lines

and then I will say that

contact

us

and then I will write here

No. I will not return a view

I will return just like this

so what will this do

we will se here

slash

contact us

so

this is

this is what is returning

see that If we have

lets say about us

then what will I do

and then

I will remove this and

about us

so this is what the route is

simple route is like this

the view file is here

so we can change

file here

and it will reflect

just like this

the home url

this is our home url

learning laravel

alright

lets check another example of route

lets say

I say about my post

I say that

there are so many posts

and I want to see the post like

ID

and I will say what ID?

I will say

it will take input here

post id

and then

(dollar) id

what will this do?

when I will write slash post

slash one

it will say this id is one

and if I say let me show the post of id 5

it will show me this

if I say that show me post of id

one two one

it will show me like this

so

this route is actually depend on input.

Không có nhận xét nào:

Đăng nhận xét