public/css/
folder<link href="{{asset('css/app.css')}}" rel="stylesheet">
public function services() {
$data = [
'title' => 'langs',
'languages' => ['PHP', 'Java', 'Python']
];
return view('pages/services')->with($data);
}
Receive the passed array@extends('layouts.app')
@section('cntnt')
<h3>{{$title}}</h3>
@if(count($languages))
@foreach($languages as $language)
<li>{{$language}}</li>
@endforeach
@endif
@endsection
with
methodpublic function about() {
$param1 = 'this is a parameter of about us page';
return view('pages/about')->with('title', $param1);
}
Content of the blade template@extends('layouts.app')
@section('cntnt')
<h3>abt us {{$title}}</h3>
@endsection
public function about() {
$param1 = 'this is a parameter of about us page';
return view('pages/about', compact('param1'));
}
Content of about
blade (the page receives and uses the passed parameter)@section('cntnt')
<h3>abt us {{$param1}}</h3>
@endsection
@yield
is mainly used to define a section in a layout.
Content of resources/views/layouts/app.blade.php
file<body>
@yield('content')
</body>
Content of about
page that extends the above layout file@extends('layouts.app')
@section('content')
// "about us" page content goes here
@endsection
ctrl + p
-> search ext install laravel blade
-> install laravel blade snippets
extensionpublic function contact() {
return 'Under Construction';
}
Returns HTMLpublic function about() {
return '<h1>About the site</h1>details...';
}
Returns view located at resources/views/pages/services.blade.php
public function services() {
return view('pages/services');
}
about
returns view from route. Other routes fire PagesController
appropriate methodsRoute::get('/', 'PagesController@index');
Route::get('/about', function () {
return view('pages.about');
});
Route::get('/services', 'PagesController@services');
Route::get('/contact', 'PagesController@contactUs');
PagesController
methodsclass 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';
}
}
Route::get('/users/{name}', function ($name) {
return 'This is a user ' . $name;
});
Two parameters passed through the request URLRoute::get('/users/{name}/{id}', function ($name, $id) {
return 'This is a user ' . $name .' with an id of '. $id;
});