Birmingham mumbai


Download 1.3 Mb.
Pdf ko'rish
bet58/68
Sana05.01.2022
Hajmi1.3 Mb.
#227543
1   ...   54   55   56   57   58   59   60   61   ...   68
Bog'liq
Laravel 5 Essentials

Performing redirections

It is also possible to redirect visitors using the 

redirect()

 helper in your routes. 

If, for example, we wanted everyone to be redirected to 

/cats


 when they visit the 

application for the first time, we would write the following lines of code:

Route::get('/', function() {

  return redirect('cats');

});



Your First Application

[

 28 

]

Now, we can create the route for the URL we're redirecting to:

Route::get('cats', function() {

  return 'All cats';

});

Returning views

The most frequent object that you will return from your routes is the 

View

 object. Views 



receive data from a route (or controller action) and inject it into a template, therefore 

helping you to separate the business and presentation logic in your application.

To add your first view, simply create a file called 

about.php

 at 

resources/views



 

and add the following content to it:




Download 1.3 Mb.

Do'stlaringiz bilan baham:
1   ...   54   55   56   57   58   59   60   61   ...   68




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling