Skip to content

Instantly share code, notes, and snippets.

@nazo
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazo/7a6109f07a624082d01e to your computer and use it in GitHub Desktop.
Save nazo/7a6109f07a624082d01e to your computer and use it in GitHub Desktop.
[php][laravel5]Laravel5付属の便利関数

Support/helplers.phpにある

studly_case

trait_uses_recursive

value

値を返すが、Closureだった場合はそれを実行した結果を返す。

value(‘a’); // ‘a'
value(function() { return ‘a’; }); // ‘a'

with

new Hoge()->fuga();ができないのを解消する。

with(new Hoge())->fuga();

やってることは来たものをそのままreturnしているだけ。

array_only

配列から指定キーのものだけ取り出す

$array = [“a” => 1, “b” => 2, “c” => 3, “d” => 4];
array_only($array, [“a”, “c”]); // [“a” => 1, “c” => 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment