Use [] to find tag! Example: [flutter, javascript]

Laravel Exploration Carefully
Laravel Exploration Carefully

Chapter 3

Route

remove_red_eye 2254 Times
spellcheck 424 Words, 2653 Characters
*Note: this book is still ongoing until it has a finished label.

Router is important for web developer. If you don't know what a router is, a router is link/direction/url settings for our website, so that users can easily go to certain pages on our website.

Source code here ok

Creating Website Routes

please open folder routes/web.php

in that folder there is code default from laravel as below

<?php

   use Illuminate\Support\Facades\Route;
  
   /*
   |------------------------------------------------- -------------------------
   | Web Routes
   |------------------------------------------------- -------------------------
   |
   | Here is where you can register web routes for your application. These
   | routes are loaded by the RouteServiceProvider within a group which
   | contains the "web" middleware group. Now create something great!
   |
   */
  
   Route::get('/', function () {
       return view('welcome');
   });
   

in the file there is the code Route::get , this code explains that the page / use view welcome. The view is located in the folder resources/view such as image below


* Inside the view folder, there is a file welcome.blade.php, that's where we can create the view We. Now let's change the contents of welcome.blade.php to something like this.

<!DOCTYPE html>
   <html lang="en">
   <head>
       <meta charset="UTF-8">
       <meta name="viewport" content="width=device-width, initial-scale=1.0">
       <meta http-equiv="X-UA-Compatible" content="ie=edge">
       <title>Welcome</title>
   </head>
   <body>
       Hello welcome
   </body>
   </html>
   

* Then we can open our website with php artisan serve  and open it in a browser.

* Now that we know what routes and views are for. Let's create a new router and views for our projects. namely router about and view about.blade.php

Code route about

Route::get('/about', function () {
       return view('about');
   });

Code view/about.blade.php

<!DOCTYPE html>
   <html lang="en">
   <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>Document</title>
   </head>
   <body>
     Hello About
   </body>
   </html>

* after creating route and about, let's try to open our website with php artisan serve and open it in the browser. Here are the results


Next we will discuss about public folders. Ok thanks guys source code here

Next Article (Pass Data from Route to View)
Content Navigation