Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In this lecture, I will introduce the concept of middleware.
So in simplest terms, the middleware is the code that runs before and after the controller, an example
job of before middleware is to limit access to only the authenticated users.
Now, the example job of after middleware is to add some headers to the response.
You can create your own middleware, though, it's also heavily used internally by Laravel to supply
typical functionality, middleware is a piece B class and it has to have at least one method called
handle.
It does not have to extend any base, class or interface.
These are two minimal examples of an before and after model where the perform action command is, where
you'd put some extra logic if you really want to understand how to make your own middleware.
It's a good idea to look at existing middleware provided with Laravel.
There are three levels of applying middleware first, global essential middleware is applied on all
routes always.
Secondly, some is applied only in Web and API routes, all of above is configurable in the kernel file,
which will take a look at in a second third level, Eastern were applied per route groups per controller
class.
You will learn about control classes in a bid or per individual route.
Let's take a look at the colonel file, which can be found inside the app HTP folder.
The middleware field defines their globally applied middleware.
The middle where groups feel that defined the Web and API roots specific middleware.
One of the root object methods is middleware.
That way, you can apply to a group of roots or a specific route now to make it a little bit easier.
You don't have to use a full class name like you've seen in the colonel file.
In this colonel be filed, there is another field called Route Middleware, and it defines a thing called
analysis.
Now using this Elias's, you can easily apply middleware using the middleware method and passing those.
Elias's using a comma separated string.
For example, if I would use that Alpha Middleware on this specific route from now on, it would require
the user to be authenticated to visit this route.
Now, the middleware also can accept parameters and we will use it later when we cover the user authorization.
Finally, let's verify if the S middleware was properly applied on this route.
So currently the route looks like this.
After refreshing this page, I should see some kind of error because we have no concept of authentication
in our application yet.
And indeed, after refreshing, you see an error.
There is nothing to worry about when you will learn about authentication in Laravel, this error would
just simply go away.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.