
Query Builder
Laravel 提供了方便易用的資料庫查詢機制,基於 PDO 參數綁定(parameter binding),保護應用程式免於 SQL資料隱碼 (SQL injection) 攻擊。Query Builder
Laravel 提供了方便易用的資料庫查詢機制,基於 PDO 參數綁定(parameter binding),保護應用程式免於 SQL資料隱碼 (SQL injection) 攻擊。Form Validation
Laravel 包含了一個 Validation 類別,專門用來處理資料驗證。使用 Validator 類別的 make() 方法來建立驗證:Validator::make(data, rules, messages, customAttributes)
參數說明:
Form
在 View 中建立表單的方法{{ Form::open(['url' => 'foo']) }}
//...
{{ Form::close() }}
使用 open 及 close 來建立一個表單。參數是以陣列的方式設定,method 預設為 POST,如果要指定其他的方法,可自行增加,例如:
{{ Form::open(['url' => 'foo', 'method' => 'put']) }}
Blade
Laravel 使用 Blade 樣板系統,所有的 Blade 樣板都要以 .blade.php 結尾。Route 進階
在微型部落格專案中,我們的 routes.php 內容是這樣:Route::get('post', 'HomeController@index');
Route::get('post/create', 'HomeController@create');
Route::post('post', 'HomeController@store');
Route::get('post/{id}', 'HomeController@show');
Route::get('post/{id}/edit', 'HomeController@edit');
Route::put('post/{id}', 'HomeController@update');
Route::delete('post/{id}', 'HomeController@destroy');
目前只有一個編輯文章的功能。假如你的網站功能很多,Route 肯定會多到難以維護,其實有幾個方法可以加以調整,本節將專注在 Route 的使用上。