1.web Routes,首先在routes/web.php的擋來使用Routes,5.2版好像在app/Http/routes.php
Route::get('/', function () {//一開始進入首頁,/這地方是網址取名稱
return view('welcome');//return view是執行resources/views裡面的welcome.blade.php
});
Route::get('content', function () {
return 'content US';//如沒像上面的return view就不會執行View的靜態網站,而是直接印出字來
});
Route::get('about', function () {
return 'about US';
});
2.Views,在routes接view。其中有簡化版練習
routes/web.php
Route::get('/', function () {
return view('welcome');
});
Route::get('content', function () {
return view('content');
});
Route::get('about', function () {
return view('about');
});
routes/web.php簡化版
Route::view('/', 'welcome');
Route::view('content-us', 'content');
Route::view('about-us', 'about');
在resources/views創建about.blade.php與content.blade.php
about.blade.php
<h1>About Us</h1>
<p>Company Name</p>
<p>123-123-1234</p>
content.blade.php
<h1>Content Us</h1>
<p>Company Name</p>
<p>123-123-1234</p>