Results: 71
Only
about
returns view from route. Other routes fire
PagesController
appropriate methods
Route::get('/', 'PagesController@index');

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

Route::get('/services', 'PagesController@services');
Route::get('/contact', 'PagesController@contactUs');
PagesController
methods
class PagesController extends Controller
{
    public function index() {
        return view('pages.index');
    }
    public function about() {
        return view('pages/about');
    }
    public function services() {
        return view('pages/services');
    }
    public function contactUs() {
        return 'Under Construction';
    }
}
Returns text with the user name passed through request URL
Route::get('/users/{name}', function ($name) {
    return 'This is a user ' . $name;
});
Two parameters passed through the request URL
Route::get('/users/{name}/{id}', function ($name, $id) {
    return 'This is a user ' . $name .' with an id of '. $id;
});
Returns view located at
resources/views/pages/about.blade.php
Route::get('/hello', function () {
    return view('pages/about');
});
pages/about
is the same as
pages.about
Visiting
/hello
page returns
<h1>
Route::get('/hello', function () {
    return '<h1>Hello World</h1>';
});
Visiting
/hello
page returns text
Hello World
Route::get('/hello', function () {
    return 'Hello World';
});
Database configuration file is located at
config/database.php
Route::get('/', function () {
    return view('welcome');
});
get
- type of HTTP request
/
- stands for the homepage
welcome
- view file located at
resources/views/welcome.blade.php
The route will return
welcome
view file content
Routes are located in
routes/web.php
All views are located in the
resources/views
folder. All laravel views use
blade
template engine. Views files contain the word in its name like
welcome.blade.php
All controllers are located in the
app/Http/Controllers
folder with plural form like
UsersController.php
in Laravel older versions but with singular form like
UserController.php
in new versions of Laravel
Results: 71