Readouble

Laravel 5.dev ヘルパ関数

配列Arrays

array_addarray_add

指定されたキー/値のペアをそのキーが存在していない場合、配列に追加します。The array_add function adds a given key / value pair to the array if the given key doesn't already exist in the array.

$array = array('foo' => 'bar');

$array = array_add($array, 'key', 'value');

array_dividearray_divide

array_divide関数は2つの配列をリターンします。一つはオリジナル配列のキー、もう一方は値です。The array_divide function returns two arrays, one containing the keys, and the other containing the values of the original array.

$array = array('foo' => 'bar');

list($keys, $values) = array_divide($array);

array_dotarray_dot

array_dot関数は多次元配列をドット記法で深さを表した一次元配列に変換します。The array_dot function flattens a multi-dimensional array into a single level array that uses "dot" notation to indicate depth.

$array = array('foo' => array('bar' => 'baz'));

$array = array_dot($array);

// array('foo.bar' => 'baz');

array_exceptarray_except

array_exceptメソッドは指定されたキーのアイテムを配列から削除した値を返します。The array_except method removes the given key / value pairs from the array.

$array = array_except($array, array('keys', 'to', 'remove'));

array_fetcharray_fetch

array_fetchメソッドは選択したネスト要素で構成された配列を一次元化して返します。The array_fetch method returns a flattened array containing the selected nested element.

$array = array(
	array('developer' => array('name' => 'Taylor')),
	array('developer' => array('name' => 'Dayle')),
);

$array = array_fetch($array, 'developer.name');

// array('Taylor', 'Dayle');

array_firstarray_first

array_firstメソッドはテストで真を返した配列中の最初の要素を返します。The array_first method returns the first element of an array passing a given truth test.

$array = array(100, 200, 300);

$value = array_first($array, function($key, $value)
{
	return $value >= 150;
});

デフォルト値を3つ目の引数で指定することもできます。A default value may also be passed as the third parameter:

$value = array_first($array, $callback, $default);

array_lastarray_last

array_lastメソッドは指定された条件にtrueを返す、配列の最後の要素をリターンします。The array_last method returns the last element of an array passing a given truth test.

$array = array(350, 400, 500, 300, 200, 100);

$value = array_last($array, function($key, $value)
{
	return $value > 350;
});

// 500

デフォルト値を3つ目の引数で指定することもできます。A default value may also be passed as the third parameter:

$value = array_last($array, $callback, $default);

array_flattenarray_flatten

array_flattenメソッドは、多次元配列を一次元配列へ変換します。The array_flatten method will flatten a multi-dimensional array into a single level.

$array = array('name' => 'Joe', 'languages' => array('PHP', 'Ruby'));

$array = array_flatten($array);

// array('Joe', 'PHP', 'Ruby');

array_forgetarray_forget

array_forgetメソッドはドット記法で指定されたキーと値のペアを深くネストされた配列から取り除きます。The array_forget method will remove a given key / value pair from a deeply nested array using "dot" notation.

$array = array('names' => array('joe' => array('programmer')));

array_forget($array, 'names.joe');

array_getarray_get

array_getメソッドは指定された値をドット記法で指定された値を深くネストされた配列から取得します。The array_get method will retrieve a given value from a deeply nested array using "dot" notation.

$array = array('names' => array('joe' => array('programmer')));

$value = array_get($array, 'names.joe');

$value = array_get($array, 'names.john', 'default');

注目: array_getと同じことを代わりにオブジェクトで行いたいのですか?それなら、object_getを使ってください。Note: Want something like array_get but for objects instead? Use object_get.

array_onlyarray_only

array_onlyメソッドは配列中の指定されたキーのアイテムのみをリターンします。The array_only method will return only the specified key / value pairs from the array.

$array = array('name' => 'Joe', 'age' => 27, 'votes' => 1);

$array = array_only($array, array('name', 'votes'));

array_pluckarray_pluck

array_pluckメソッドは配列から指定されたキーのリストを取得します。The array_pluck method will pluck a list of the given key / value pairs from the array.

$array = array(array('name' => 'Taylor'), array('name' => 'Dayle'));

$array = array_pluck($array, 'name');

// array('Taylor', 'Dayle');

array_pullarray_pull

array_pullメソッドは配列から指定されたキー/値ペアを取得し、同時に削除します。The array_pull method will return a given key / value pair from the array, as well as remove it.

$array = array('name' => 'Taylor', 'age' => 27);

$name = array_pull($array, 'name');

array_setarray_set

array_setメソッドはドット記法を使用し、深くネストした配列に値をセットします。。The array_set method will set a value within a deeply nested array using "dot" notation.

$array = array('names' => array('programmer' => 'Joe'));

array_set($array, 'names.editor', 'Taylor');

array_sortarray_sort

array_sortメソッドは指定されたクロージャーの実行結果に基づき、配列をソートします。The array_sort method sorts the array by the results of the given Closure.

$array = array(
	array('name' => 'Jill'),
	array('name' => 'Barry'),
);

$array = array_values(array_sort($array, function($value)
{
	return $value['name'];
}));

array_wherearray_where

指定されたクロージャーで、配列をフィルタリングします。Filter the array using the given Closure.

$array = array(100, '200', 300, '400', 500);

$array = array_where($array, function($key, $value)
{
	return is_string($value);
});

// Array ( [1] => 200 [3] => 400 )

headhead

配列の最初の要素を返します。PHP5.3.xでメソッドチェーン時に便利です。Return the first element in the array. Useful for method chaining in PHP 5.3.x.

$first = head($this->returnsArray('foo'));

lastlast

配列の最後の要素を返します。メソッドチェーン時に便利です。Return the last element in the array. Useful for method chaining.

$last = last($this->returnsArray('foo'));

パスPaths

app_pathapp_path

appディレクトリーへの完全パスを取得します。Get the fully qualified path to the app directory.

$path = app_path();

base_pathbase_path

アプリケーションをインストールしたルート(一番上)への完全パスを取得します。Get the fully qualified path to the root of the application install.

public_pathpublic_path

publicディレクトリーへの完全パスを取得します。Get the fully qualified path to the public directory.

storage_pathstorage_path

app/storageディレクトリーへの完全パスを取得します。Get the fully qualified path to the app/storage directory.

文字列Strings

camel_casecamel_case

文字列をキャメルケース(2つ目以降の単語の先頭は大文字)へ変換します。Convert the given string to camelCase.

$camel = camel_case('foo_bar');

// fooBar

class_basenameclass_basename

指定されたクラス名から名前空間を除いた、クラス名だけを取得します。Get the class name of the given class, without any namespace names.

$class = class_basename('Foo\Bar\Baz');

// Baz

ee

指定された文字列にhtmlentitesを実行します。UTF-8サポートです。Run htmlentities over the given string, with UTF-8 support.

$entities = e('<html>foo</html>');

ends_withends_with

最初の文字列が、2つ目の引数の文字列で終わっているか調べます。Determine if the given haystack ends with a given needle.

$value = ends_with('This is my name', 'name');

snake_casesnake_case

文字列をスネークケース(小文字名下線区切り)に変換します。Convert the given string to snake_case.

$snake = snake_case('fooBar');

// foo_bar

str_limitstr_limit

文字列を文字数へ短くします。Limit the number of characters in a string.

str_limit($value, $limit = 100, $end = '...')

例:Example:

$value = str_limit('The PHP framework for web artisans.', 7);

// The PHP...

starts_withstarts_with

指定された文字列が、2番めの文字列で始まっているか調べます。Determine if the given haystack begins with the given needle.

$value = starts_with('This is my name', 'This');

str_containsstr_contains

指定された文字列が、2つ目の文字列を含んでいるか調べます。Determine if the given haystack contains the given needle.

$value = str_contains('This is my name', 'my');

str_finishstr_finish

指定された文字列の最後に2つ目の文字列を一つだけ付けます。重複している場合も1つだけ付けた文字列にします。Add a single instance of the given needle to the haystack. Remove any extra instances.

$string = str_finish('this/string', '/');

// this/string/

str_isstr_is

指定された文字列がパターンに一致しているかを判定します。アスタリスクが使用されるとワイルドカードとして利用されます。Determine if a given string matches a given pattern. Asterisks may be used to indicate wildcards.

$value = str_is('foo*', 'foobar');

str_pluralstr_plural

文字列を複数形にします。(英語のみ)Convert a string to its plural form (English only).

$plural = str_plural('car');

str_randomstr_random

指定された長さのランダムな文字列を生成します。Generate a random string of the given length.

$string = str_random(40);

str_singularstr_singular

文字列を単数形にします。(英語のみ)Convert a string to its singular form (English only).

$singular = str_singular('cars');

str_slugstr_slug

指定された文字列から、URLフレンドリーな「スラグ」を生成します。Generate a URL friendly "slug" from a given string.

str_slug($title, $separator);

例:Example:

$title = str_slug("Laravel 5 Framework", "-");

// laravel-5-framework

studly_casestudly_case

文字列をアッパーキャメルケース(単語の頭文字を大文字)に変換します。Convert the given string to StudlyCase.

$value = studly_case('foo_bar');

// FooBar

transtrans

指定された言語行を翻訳します。Lang::getのエイリアスです。Translate a given language line. Alias of Lang::get.

$value = trans('validation.required'):

trans_choicetrans_choice

指定された言語行を数値をもとに翻訳します。Lang::choiceのエイリアスです。Translate a given language line with inflection. Alias of Lang::choice.

$value = trans_choice('foo.bar', $count);

URLURLs

actionaction

指定されたコントローラーアクションへのURLを生成します。Generate a URL for a given controller action.

$url = action('HomeController@getIndex', $params);

routeroute

指定された名前付きルートへのURLを生成します。Generate a URL for a given named route.

$url = route('routeName', $params);

assetasset

アセット(publicディレクトリー中のファイル)へのURLを生成します。Generate a URL for an asset.

$url = asset('img/photo.jpg');

link_tolink_to

指定されたURLへのHTMLリンクを生成します。Generate a HTML link to the given URL.

echo link_to('foo/bar', $title, $attributes = array(), $secure = null);

link_to_assetlink_to_asset

指定されたアセットへのHTMLリンクを生成します。Generate a HTML link to the given asset.

echo link_to_asset('foo/bar.zip', $title, $attributes = array(), $secure = null);

link_to_routelink_to_route

指定されたルートへのHTMLリンクを生成します。Generate a HTML link to the given route.

echo link_to_route('route.name', $title, $parameters = array(), $attributes = array());

link_to_actionlink_to_action

指定されたコントローラーアクションへのHTMLリンクを生成します。Generate a HTML link to the given controller action.

echo link_to_action('HomeController@getIndex', $title, $parameters = array(), $attributes = array());

secure_assetsecure_asset

指定されたアセットへHTTPSを使用したHTMLリンクを生成します。Generate a HTML link to the given asset using HTTPS.

echo secure_asset('foo/bar.zip', $title, $attributes = array());

secure_urlsecure_url

指定されたパスへHTTPSを使用した完全なURLを生成します。Generate a fully qualified URL to a given path using HTTPS.

echo secure_url('foo/bar', $parameters = array());

urlurl

指定されたパスへの完全なURLを生成します。Generate a fully qualified URL to the given path.

echo url('foo/bar', $parameters = array(), $secure = null);

その他Miscellaneous

csrf_tokencsrf_token

現在のCSRFトークンの値を取得します。Get the value of the current CSRF token.

$token = csrf_token();

dddd

指定された変数の内容を表示し、スクリプトの実行を停止します。Dump the given variable and end execution of the script.

dd($value);

valuevalue

指定された値がクロージャーであれば、そのクロージャー内からリターンされた値を返します。そうでない場合は、値を返します。If the given value is a Closure, return the value returned by the Closure. Otherwise, return the value.

$value = value(function() { return 'bar'; });

withwith

指定されたオブジェクトをリターンします。PHP 5.3.xでメソッドチェーンのコンストラクターとして便利です。Return the given object. Useful for method chaining constructors in PHP 5.3.x.

$value = with(new Foo)->doWork();

章選択

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!…]形式の挿入削除行の表示形式です。

Pagination和文
ペジネーション
ペギネーション
ページネーション
ページ付け
Scaffold和文
スカフォールド
スキャフォールド
型枠生成
本文フォント

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

コードフォント

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

保存内容リセット

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

ヘッダー項目移動

キーボード操作