建立分支
git checkout master
git checkout -b static-pages
配置路由
<?php
Route::get('/', 'StaticPagesController@home');
Route::get('/help', 'StaticPagesController@help');
Route::get('/about', 'StaticPagesController@about');
生成靜態頁面控制器
$ php artisan make:controller StaticPagesController
app/Http/Controllers/StaticPagesController.php下的程式碼
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class StaticPagesController extends Controller
{
//
}
新增三個方法處理從路由發過來的請求:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class StaticPagesController extends Controller
{
public function home()
{
return '主頁';
}
public function help()
{
return '幫助頁';
}
public function about()
{
return '關於頁';
}
}
新增靜態頁面檢視
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class StaticPagesController extends Controller
{
public function home()
{
return view('static_pages/home');
}
public function help()
{
return view('static_pages/help');
}
public function about()
{
return view('static_pages/about');
}
}
blade模版與通用檢視
resources/views/layouts/default.blade.php
@yield('content')
resources/views/static_pages/home.blade.php
@extends('layouts.default')
@section('content')
//
@stop
程式碼版本控制
git add -A
git commit -m "靜態頁面"
最後合併分支
git merge static-pages
本作品採用《CC 協議》,轉載必須註明作者和本文連結