2. Basic Routing and Views

Description

Laravel 5.4 From Scratch (Laravel) Slide Set on 2. Basic Routing and Views, created by mohammed al-obadi on 08/10/2017.
mohammed al-obadi
Slide Set by mohammed al-obadi, updated more than 1 year ago
mohammed al-obadi
Created by mohammed al-obadi about 7 years ago
13
0

Resource summary

Slide 1

    https://laravel.com/docs/5.4/routing All Laravel routes are defined in your route files, which are located in the `routes` directory.  For most applications, you will begin by defining routes in your `routes/web.php` file. The `routes/web.php` file defines routes that are for your web interface. These routes are assigned the web middleware group, which provides features like session state and CSRF protection. In this tutorial you will make some Route::get() calls with different arguments in the `routes/web.php` file. Laravel::problem => view('welcome'); vs View::make('welcome') Route::get('/', function () {     return view('welcome'); }); Route::get('about', function () {     return 'About content goes here. Route 1'; }); Route::get('about/directions', function () {     return 'Directions content go here. Route 2'; }); Route::get('about/{theSubject}', function ($theSubject) {     return $theSubject . ' content goes here. Route 3'; }); Route::get('about/classes/{theSubject}', function ($theSubject) {     return "Content of {$theSubject} class goes here. Route 4"; }); Route::get('about/{name?}', function ($name = 'John') {     return "Passed name was: $name  Route para"; }); To see and try this code open: http://localhost:8000/  
    1. Handling routing

Slide 2

    Views are stored in the path: `resources/views` You will find the view file `welcome.blade.php` This is the view file that you have noticed called in `routes/web.php`. Route::get('/', function () {     return view('welcome'); }); And this is the main webpage view that you see when you access: http://localhost:8000/ - - - - - - - - - - We will add a CSS file, this file will be linked to from `welcome.blade.php` Go to `public/css` Create a new CSS file named for example `main.css` Now go to `welcome.blade.php` and in the <head> section add this line:<link rel="stylesheet" href="<?php echo asset('css/main.css'); ?>" type="text/css" > Try and use any CSS rules in the view `welcome.blade.php` to see if it works. Note that asset('css/main.css'); does not mention `public` folder, and that is because asset() targets the `public` folder by default. You can use asset() to link to JavaScript files, images, or any other assets into your Laravel view as long as those assets are in the `public` folder.  
    2. Establishing an HTML view
Show full summary Hide full summary

Similar

Calendar Mind Map
Seth Tepfer
39. Culture Affects How People Think
Lisbeth Ramirez
Intro to Engineering Design Posttest
Selam H
Network Layer & Routing
Liam-Beckwith
Eigrp note
jitendratippat
Org Setup II
Jennifer w
NTEN 137
j.salvino
Administrative Distance
River L.
Body Planes & Sections
Morgan Bolens
1. Laravel Installation and Composer
mohammed al-obadi
6. Working With the Query Builder
mohammed al-obadi