Readouble

Laravel 4.2 Requests & Input

Basic Input

You may access all user input with a few simple methods. You do not need to worry about the HTTP verb used for the request, as input is accessed in the same way for all verbs.

Retrieving An Input Value

$name = Input::get('name');

Retrieving A Default Value If The Input Value Is Absent

$name = Input::get('name', 'Sally');

Determining If An Input Value Is Present

if (Input::has('name'))
{
	//
}

Getting All Input For The Request

$input = Input::all();

Getting Only Some Of The Request Input

$input = Input::only('username', 'password');

$input = Input::except('credit_card');

When working on forms with "array" inputs, you may use dot notation to access the arrays:

$input = Input::get('products.0.name');

Note: Some JavaScript libraries such as Backbone may send input to the application as JSON. You may access this data via Input::get like normal.

Cookies

All cookies created by the Laravel framework are encrypted and signed with an authentication code, meaning they will be considered invalid if they have been changed by the client.

Retrieving A Cookie Value

$value = Cookie::get('name');

Attaching A New Cookie To A Response

$response = Response::make('Hello World');

$response->withCookie(Cookie::make('name', 'value', $minutes));

Queueing A Cookie For The Next Response

If you would like to set a cookie before a response has been created, use the Cookie::queue() method. The cookie will automatically be attached to the final response from your application.

Cookie::queue($name, $value, $minutes);

Creating A Cookie That Lasts Forever

$cookie = Cookie::forever('name', 'value');

Old Input

You may need to keep input from one request until the next request. For example, you may need to re-populate a form after checking it for validation errors.

Flashing Input To The Session

Input::flash();

Flashing Only Some Input To The Session

Input::flashOnly('username', 'email');

Input::flashExcept('password');

Since you often will want to flash input in association with a redirect to the previous page, you may easily chain input flashing onto a redirect.

return Redirect::to('form')->withInput();

return Redirect::to('form')->withInput(Input::except('password'));

Note: You may flash other data across requests using the Session class.

Retrieving Old Data

Input::old('username');

Files

Retrieving An Uploaded File

$file = Input::file('photo');

Determining If A File Was Uploaded

if (Input::hasFile('photo'))
{
	//
}

The object returned by the file method is an instance of the Symfony\Component\HttpFoundation\File\UploadedFile class, which extends the PHP SplFileInfo class and provides a variety of methods for interacting with the file.

Determining If An Uploaded File Is Valid

if (Input::file('photo')->isValid())
{
	//
}

Moving An Uploaded File

Input::file('photo')->move($destinationPath);

Input::file('photo')->move($destinationPath, $fileName);

Retrieving The Path To An Uploaded File

$path = Input::file('photo')->getRealPath();

Retrieving The Original Name Of An Uploaded File

$name = Input::file('photo')->getClientOriginalName();

Retrieving The Extension Of An Uploaded File

$extension = Input::file('photo')->getClientOriginalExtension();

Retrieving The Size Of An Uploaded File

$size = Input::file('photo')->getSize();

Retrieving The MIME Type Of An Uploaded File

$mime = Input::file('photo')->getMimeType();

Request Information

The Request class provides many methods for examining the HTTP request for your application and extends the Symfony\Component\HttpFoundation\Request class. Here are some of the highlights.

Retrieving The Request URI

$uri = Request::path();

Retrieving The Request Method

$method = Request::method();

if (Request::isMethod('post'))
{
	//
}

Determining If The Request Path Matches A Pattern

if (Request::is('admin/*'))
{
	//
}

Get The Request URL

$url = Request::url();

Retrieve A Request URI Segment

$segment = Request::segment(1);

Retrieving A Request Header

$value = Request::header('Content-Type');

Retrieving Values From $_SERVER

$value = Request::server('PATH_INFO');

Determining If The Request Is Over HTTPS

if (Request::secure())
{
	//
}

Determine If The Request Is Using AJAX

if (Request::ajax())
{
	//
}

Determine If The Request Has JSON Content Type

if (Request::isJson())
{
	//
}

Determine If The Request Is Asking For JSON

if (Request::wantsJson())
{
	//
}

Checking The Requested Response Format

The Request::format method will return the requested response format based on the HTTP Accept header:

if (Request::format() == 'json')
{
	//
}

章選択

Artisan CLI

設定

明暗テーマ
light_mode
dark_mode
brightness_auto システム設定に合わせる
テーマ選択
photo_size_select_actual デフォルト
photo_size_select_actual モノクローム(白黒)
photo_size_select_actual Solarized風
photo_size_select_actual GitHub風(青ベース)
photo_size_select_actual Viva(黄緑ベース)
photo_size_select_actual Happy(紫ベース)
photo_size_select_actual Mint(緑ベース)
コードハイライトテーマ選択

明暗テーマごとに、コードハイライトのテーマを指定できます。

テーマ配色確認
スクリーン表示幅
640px
80%
90%
100%

768px以上の幅があるときのドキュメント部分表示幅です。

インデント
無し
1rem
2rem
3rem
原文確認
原文を全行表示
原文を一行ずつ表示
使用しない

※ 段落末のEボタンへカーソルオンで原文をPopupします。

Diff表示形式
色分けのみで区別
行頭の±で区別
削除線と追記で区別

※ [tl!…]形式の挿入削除行の表示形式です。

テストコード表示
両コード表示
Pestのみ表示
PHPUnitのみ表示
和文変換

対象文字列と置換文字列を半角スペースで区切ってください。(最大5組各10文字まで)

本文フォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

コードフォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

保存内容リセット

localStrageに保存してある設定項目をすべて削除し、デフォルト状態へ戻します。

ヘッダー項目移動

キーボード操作