{"id":320,"date":"2018-02-23T01:28:29","date_gmt":"2018-02-22T16:28:29","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=320"},"modified":"2018-02-23T01:28:29","modified_gmt":"2018-02-22T16:28:29","slug":"laravel%e3%81%ae%e3%82%88%e3%81%8f%e4%bd%bf%e3%81%86%e3%83%98%e3%83%ab%e3%83%91%e3%83%bc%e9%96%a2%e6%95%b0%ef%bc%97%e9%81%b8%ef%bc%81","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=320","title":{"rendered":"Laravel\u306e\u3088\u304f\u4f7f\u3046\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\uff17\u9078\uff01"},"content":{"rendered":"<p>\u3055\u3066\u3001<strong><a class=\"row-title\" href=\"https:\/\/blog.capilano-fw.com\/?p=289\" aria-label=\"\u300c\u3010Laravel5.6\u3011\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u76f4\u5f8c\u306b\u3084\u308b\u3053\u3068\uff13\u70b9\u300d (\u7de8\u96c6)\">\u3010Laravel5.6\u3011\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u76f4\u5f8c\u306b\u3084\u308b\u3053\u3068\uff13\u70b9<\/a><\/strong>\u306a\u3069\u3053\u3053\u306e\u6240Laravel\u306e\u8a71\u984c\u304c\u591a\u304f\u306a\u3063\u3066\u308b\u308f\u3051\u3067\u3059\u3051\u3069\u3001\u305d\u3093\u306a\u4e2d\u3001\u3075\u3068\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3092\u767a\u898b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/laravel-news.com\/5-laravel-helpers-make-life-easier\" target=\"_blank\" rel=\"noopener\">5 Laravel Helpers to Make Your Life Easier<\/a><\/p>\n<p>\u610f\u8a33\u3059\u308b\u3068\u3001\u300c<strong>\u958b\u767a\u304c\u697d\u301c\u306b\u306a\u3063\u3061\u3083\u3046\u3001Laravel\u306e\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\uff15\u3064<\/strong>\u300d<\/p>\n<p>\u3063\u3066\u611f\u3058\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u305f\u3060\u3001\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3093\u3067\u3093\u3067\u3059\u3051\u3069\u3001\u6b63\u76f4\u306a\u6240\u300c\u3093\u30fc\u3001\u305d\u308c\u306f\u5fae\u5999\u304b\u306a\u30fb\u30fb\u30fb\u300d\u3063\u3066\u601d\u3046\u3082\u306e\u3082\u5165\u3063\u3066\u305f\u3093\u3067\u3001\u3058\u3083\u3042\u4eca\u5ea6\u306f\u50d5\u81ea\u8eab\u304c\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">Laravel\u306e\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u3067\u300c\u5b9f\u969b\u3088\u304f\u4f7f\u3063\u3066\u308b\u3082\u306e\u300d<\/strong><\/p>\n<p>\u3092\u307e\u3068\u3081\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<br \/>\n\u3088\u304b\u3063\u305f\u3089\u3001\u307f\u306a\u3055\u3093\u3068\u6bd4\u3079\u306a\u304c\u3089\u8aad\u3093\u3067\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<h1>\uff11\uff0eauth()<\/h1>\n<p>auth() \u306f\u30db\u30f3\u30c8\u306b\u3088\u304f\u4f7f\u3046\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\n\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30ed\u30b0\u30a4\u30f3\u30e6\u30fc\u30b6\u30fc\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3057\u3001<\/p>\n<pre><strong>$user = auth()-&gt;user();<\/strong><\/pre>\n<p>\u30ed\u30b0\u30a4\u30f3\u30c1\u30a7\u30c3\u30af\u3082\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>if(auth()-&gt;check()) {<\/strong>\r\n\r\n<strong>    \/\/ \u30ed\u30b0\u30a4\u30f3\u6e08\u307f<\/strong>\r\n\r\n<strong>}<\/strong><\/pre>\n<p>\u3042\u3068\u306f\u3001\u3053\u3093\u306a\u30ab\u30f3\u30b8\u3067ID\u3092\u4f7f\u3063\u3066\u30ed\u30b0\u30a4\u30f3\u3055\u305b\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3057\u3001<\/p>\n<pre><strong>auth()-&gt;loginUsingId(1)<\/strong><\/pre>\n<p>Blade\u306e\u4e2d\u3067\u3001<\/p>\n<pre><strong>{{ auth()-&gt;user()-&gt;name }}<\/strong><\/pre>\n<p>\u306a\u3093\u3066\u3044\u3046\u98a8\u306b\u30ed\u30b0\u30a4\u30f3\u4e2d\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u53d6\u5f97\u3057\u305f\u308a\u3057\u307e\u3059\u3002<br \/>\n\u591a\u5206\u3001\u3053\u306e\u5f62\u3060\u3068\u30c7\u30b6\u30a4\u30ca\u30fc\u3055\u3093\u304c\u898b\u3066\u3082\u5206\u304b\u308a\u3084\u3059\u3044\u3068\u601d\u3046\u3093\u3067\u3059\u3088\u306d\u3002\uff08\u6700\u8fd1\u306fVue\u5316\u3059\u308b\u3053\u3068\u3082\u591a\u3044\u3067\u3059\u3051\u3069\uff09<\/p>\n<p>\u305f\u3060\u3057\u3001<strong>$request<\/strong>\u304c\u3042\u308b\u5834\u5408\uff08\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u5185\u3068\u304b\uff09\u3060\u3068\u3001<\/p>\n<pre><strong>$request-&gt;user();<\/strong><\/pre>\n<p>\u3068\u3059\u308b\u3053\u3068\u3082\u591a\u3044\u3067\u3059\u3002<\/p>\n<h1>\uff12\uff0eenv(), config()<\/h1>\n<p>\u3069\u3061\u3089\u3082\u7279\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u304b\u3089\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u3060\u3059\u3082\u306e\u306a\u306e\u3067\u3001\uff12\u3064\u4e00\u7dd2\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u307e\u305a\u3072\u3068\u3064\u3081\u306f\u3001<strong>.env<\/strong>\u306e\u4e2d\u306b\u66f8\u304b\u308c\u3066\u3042\u308b\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3059\u308b\u306e\u306b\u4f7f\u3044\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001<strong>.env<\/strong>\u306b<\/p>\n<pre><strong>APP_NAME=Laravel<\/strong><\/pre>\n<p>\u3068\u66f8\u304b\u308c\u3066\u3044\u305f\u3089\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>echo <strong>env('APP_NAME');<\/strong><\/pre>\n<p>\u203b\u305f\u3060\u3057\u3001<strong>.env<\/strong>\u306e\u5834\u5408\u306f\u914d\u5217\u3092\u6307\u5b9a\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u6587\u5b57\u5217\u306e\u307f\u306b\u306a\u308a\u307e\u3059\u3002\u7121\u7406\u3084\u308ajson\u6587\u5b57\u5217\u3092\u4f7f\u3063\u3066\u5bfe\u51e6\u3059\u308b\u65b9\u6cd5\u3082\u3042\u308b\u3089\u3057\u3044\u306e\u3067\u3059\u304c\u3001\u3042\u307e\u308a\u30b9\u30de\u30fc\u30c8\u3058\u3083\u306a\u3044\u3068\u601d\u3046\u306e\u3067\u4eca\u56de\u306f\u30d1\u30b9\u3002<\/p>\n<p>\u3067\u3001\u6b21\u306b<strong>config()<\/strong>\u3002\u3053\u308c\u3082<strong>env()<\/strong>\u3068\u307b\u307c\u540c\u3058\u306a\u3093\u3067\u3059\u3051\u3069\u3001\u547c\u3073\u51fa\u3057\u306b<strong>config\u30d5\u30a9\u30eb\u30c0<\/strong>\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u95a2\u308f\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001config\/<strong>app.php<\/strong>\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3068\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<pre>&lt;?php\r\n\r\nreturn [\r\n \/***  \u9577\u3044\u306e\u3067\u7701\u7565  ***\/\r\n <strong>'xxx' =&gt; 'yyy'<\/strong>\r\n];<\/pre>\n<p>\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>echo <strong>config('app.xxx');<\/strong> \/\/ yyy<\/pre>\n<p>\u3064\u307e\u308a\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u3068\u30ad\u30fc\u3092\u30c9\u30c3\u30c8\u3067\u3064\u306a\u3050\u3053\u3068\u3067\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u308f\u3051\u3067\u3059\u306d\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001.env()\u3068\u306e\u3082\u3046\u3072\u3068\u3064\u306e\u9055\u3044\u306f\u3001<strong>\u914d\u5217\u306b\u5bfe\u5fdc\u3057\u3066\u308b<\/strong>\u3068\u3044\u3046\u3053\u3068\u3002<br \/>\n\u3082\u3057\u3055\u3063\u304d\u306e\u8a18\u8ff0\u304c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u914d\u5217\u3060\u3063\u305f\u3089\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<pre>&lt;?php\r\n\r\nreturn [\r\n \/***  \u9577\u3044\u306e\u3067\u7701\u7565  ***\/\r\n<strong>\u00a0 'xxx' =&gt; [<\/strong>\r\n<strong>    'yyy_1' =&gt; 'zzz_1',<\/strong>\r\n<strong>    'yyy_2' =&gt; 'zzz_2',<\/strong>\r\n<strong>    'yyy_3' =&gt; 'zzz_3'<\/strong>\r\n<strong>  ]<\/strong>\r\n];<\/pre>\n<p>\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u306f\u4ee3\u308f\u308a\u307e\u305b\u3093\u3051\u3069\u3001\u4e2d\u8eab\u306f\u914d\u5217\u3068\u3057\u3066\u8fd4\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<pre>$array = <strong>config('app.xxx');<\/strong> \/\/ \u914d\u5217<\/pre>\n<p>\u305d\u3057\u3066\u3001\u3055\u3089\u306b\u30c9\u30c3\u30c8\u3092\u3064\u306a\u3050\u3053\u3068\u3067\u914d\u5217\u306e\u4e2d\u8eab\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>echo <strong>config('app.key.xxx.yyy_1')<\/strong>; \/\/ zzz_1<\/pre>\n<h1>\uff13\uff0ecollect()<\/h1>\n<p>\u3053\u306e\u95a2\u6570\u306f\u914d\u5217\u3092\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u308b\u3093\u3067\u3059\u3051\u3069\u3001\u4f7f\u3044\u65b9\u306b\u3088\u3063\u3066\u306f\u306a\u304b\u306a\u304b\u4fbf\u5229\u306a\u3093\u3067\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u6b21\u306e\u3088\u3046\u306a\u914d\u5217\u304c\u3042\u3063\u305f\u3068\u3057\u307e\u3059\u3002\uff08\u7279\u306bjson\u304b\u3089\u30c7\u30fc\u30bf\u53d6\u5f97\u3057\u305f\u3068\u304d\u306a\u3093\u304b\u3067\u3059\u306d\uff09<\/p>\n<pre><strong>$products = [<\/strong>\r\n<strong>    [<\/strong>\r\n<strong>        'id' =&gt; 1,<\/strong>\r\n<strong>        'name' =&gt; 'xxx'<\/strong>\r\n<strong>    ],<\/strong>\r\n<strong>    [<\/strong>\r\n<strong>        'id' =&gt; 2,<\/strong>\r\n<strong>        'name' =&gt; 'yyy'<\/strong>\r\n<strong>    ],<\/strong>\r\n<strong>    [<\/strong>\r\n<strong>        'id' =&gt; 3,<\/strong>\r\n<strong>        'name' =&gt; 'zzz'<\/strong>\r\n<strong>    ],<\/strong>\r\n<strong>];<\/strong><\/pre>\n<p>\u3053\u306e\u5834\u5408\u306b\u3001<\/p>\n<p>ID\u304c\uff13\u306e\u540d\u524d\uff08name\uff09\u3092\u53d6\u5f97\u3057\u305f\u3044\u3063\u3066\u306a\u3063\u305f\u3089\u3001\u3069\u3046\u3067\u3057\u3087\u3046\u3002<br \/>\nforeach() \u3068\u304b\u306e\u30eb\u30fc\u30d7\u3060\u3068\u3061\u3087\u3063\u3068\u66f8\u304f\u306e\u304c\u9762\u5012\u3060\u3063\u305f\u308a\u3057\u307e\u3059\u3088\u306d\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bcollect()\u3092\u4f7f\u3063\u3066\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u4fbf\u5229\u6a5f\u80fd\u3067\u7c21\u5358\u306b\u5b9f\u73fe\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre><strong>$product = collect($products)-&gt;firstWhere('id', 3);<\/strong>\r\n<strong>echo $product['name']; \/\/ zzz<\/strong><\/pre>\n<p><a href=\"https:\/\/laravel.com\/docs\/5.6\/collections\" target=\"_blank\" rel=\"noopener\">\u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/a>\u306e\u95a2\u6570\u306f\u306b\u306f\u4ed6\u306b\u3082\u305f\u304f\u3055\u3093\u3042\u308b\u306e\u3067\u305c\u3072\u672c\u5bb6\u306e\u30b5\u30a4\u30c8\u3067\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u203b <strong>firstWhere()<\/strong>\u306fLaravel5.5\u4ee5\u964d\u3067\u6709\u52b9\u3067\u3059\u3002\u305d\u308c\u4ee5\u524d\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f<strong>first()<\/strong>\u3067\u5bfe\u5fdc\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>\uff14\uff0estarts_with(), ends_with()<\/h1>\n<p>\u610f\u5916\u3068\u3001\u3042\u3063\u3066\u5b09\u3057\u3044\u306e\u304c\u3053\u306e\uff12\u3064\u3067\u3059\u3002\u7279\u5b9a\u306e\u6587\u5b57\u5217\u3067\u59cb\u307e\u3063\u3066\u308b\u304b\u3001\u7d42\u308f\u3063\u3066\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u95a2\u6570\u306a\u3093\u3067\u3059\u3051\u3069\u3001\u3053\u308c\u3063\u3066\u3082\u3068\u3082\u3068PHP\u306b\u6a19\u6e96\u95a2\u6570\u3068\u3057\u3066\u3044\u308c\u3068\u3044\u3066\u3088\u30fc\u3002\u3068\u601d\u3046\u30ec\u30d9\u30eb\u306a\u306e\u306b\u3001\u306a\u3093\u3067\u306a\u3044\u306e\u304b\u306a\uff1f\uff1f\u4ed6\u306b\u3082\u3063\u3068\u3044\u3089\u306a\u3044\u30fb\u30fb\u30fb\u3044\u3084\u3001\u4f7f\u7528\u983b\u5ea6\u304c\u4f4e\u3044\u95a2\u6570\u306a\u3093\u3066\u5c71\u307b\u3069\u3042\u308b\u306e\u306b\uff08\u7b11\uff09<\/p>\n<p>\u4f7f\u3044\u65b9\u306f\u3053\u3093\u306a\u30ab\u30f3\u30b8\u3067\u3059\u3002<br \/>\n\u30de\u30eb\u30c1\u30d0\u30a4\u30c8\u6587\u5b57\u306b\u3082\u5bfe\u5fdc\u3057\u3066\u308b\u306e\u304c\u5b09\u3057\u3044\u3067\u3059\u306d\u3002<\/p>\n<pre><strong>$str = '\u304a\u8179\u3044\u3063\u3071\u3044\u3067\u5e78\u305b';<\/strong>\r\n\r\n<strong>if(starts_with($str, '\u304a\u8179')) {<\/strong>\r\n\r\n<strong>    echo '\u300c\u304a\u8179\u300d\u304b\u3089\u59cb\u307e\u308b\u6587\u5b57\u5217\u3067\u3059';<\/strong>\r\n\r\n<strong>}<\/strong>\r\n\r\n<strong>if(ends_with($str, '\u5e78\u305b')) {<\/strong>\r\n\r\n<strong>    echo '\u300c\u5e78\u305b\u300d\u3067\u7d42\u308f\u308b\u6587\u5b57\u5217\u3067\u3059';<\/strong>\r\n\r\n<strong>}<\/strong><\/pre>\n<h1>\uff15\uff0etrans()<\/h1>\n<p>\u3053\u306e\u95a2\u6570\u306f\u4fbf\u5229\u3068\u3044\u3046\u304b\u3001Laravel\u3067\u591a\u8a00\u8a9e\u5bfe\u5fdc\u3059\u308b\u306a\u3089\u5fc5\u9808\u3068\u8a00\u3063\u3066\u3044\u3044\u95a2\u6570\u3067\u3059\u306d\u3002<\/p>\n<p>\u4f7f\u3044\u65b9\u306f\u307b\u307c<strong>config()<\/strong>\u3068\u540c\u3058\u3067\u3001<\/p>\n<p><strong>\/lang\/xx\/auth.php<\/strong>\u5185\u306b\uff08xx\u306f\u30ed\u30b1\u30fc\u30eb\u6587\u5b57\u5217\u3002\u4f8b\uff1aja, en\uff09<\/p>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>return [<\/strong>\r\n<strong>    'complete' =&gt; '\u30ed\u30b0\u30a4\u30f3\u6210\u529f\uff01',<\/strong>\r\n<strong>];<\/strong><\/pre>\n<p>\u3068\u66f8\u3044\u3066\u3042\u308c\u3070\u3001<\/p>\n<pre>echo <strong>trans('auth.complete');<\/strong><\/pre>\n<p>\u3068\u3059\u308c\u3070\u3001\u81ea\u52d5\u3067\u5bfe\u5fdc\u8a00\u8a9e\u306e\u6587\u5b57\u5217\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u6587\u5b57\u5217\u306e\u4e00\u90e8\u3092\u53ef\u5909\u306b\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u3066\u3001<\/p>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>return [<\/strong>\r\n<strong>    'complete' =&gt; '\u30ed\u30b0\u30a4\u30f3\u306b :count \u56de\u6210\u529f\uff01',<\/strong>\r\n<strong>];<\/strong><\/pre>\n<p>\u3068\u7ffb\u8a33\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u3044\u3066\u304a\u3044\u3066\u3001<\/p>\n<pre>echo <strong>trans('auth.complete', ['count' =&gt; 3]);<\/strong><\/pre>\n<p>\u3068\u3059\u308c\u3070\u3001\u300c<strong>\u30ed\u30b0\u30a4\u30f3\u306b 3 \u56de\u6210\u529f\uff01<\/strong>\u300d\u3068\u8868\u793a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b\u3061\u306a\u307f\u306b\u3001Blade\u306e\u5185\u90e8\u3060\u3068\u3001\u4ee3\u308f\u308a\u306b<strong>@lang<\/strong>\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\uff16\uff0earray_get()<\/h1>\n<p>array_get()\u306f\u3001<strong>\u914d\u5217\u306e\u4e2d\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/strong>\u6642\u306b\u4f7f\u3046\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u306a\u3093\u3067\u3059\u3051\u3069\u3001\u306a\u305c\u901a\u5e38\u901a\u308a\u306b\u3001<\/p>\n<pre><strong>$array['key_1']['key_2'];<\/strong><\/pre>\n<p>\u3068\u3044\u3046\u5f62\u306b\u3057\u306a\u3044\u304b\u3068\u8a00\u3046\u3068\u3001<\/p>\n<ol>\n<li>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a\u3067\u304d\u308b<\/li>\n<li>\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u3084\u3059\u3044<\/li>\n<\/ol>\n<p>\u306e\uff12\u70b9\u306b\u3064\u304d\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306e\u4f7f\u3044\u65b9\u3067\u3059\u3002<\/p>\n<pre><strong>$array = [<\/strong>\r\n<strong>    'japan' =&gt; [<\/strong>\r\n<strong>        'tokyo' =&gt; [<\/strong>\r\n<strong>            'kanji' =&gt; '\u6771\u4eac'<\/strong>\r\n<strong>        ],<\/strong>\r\n<strong>        'kyoto' =&gt; [<\/strong>\r\n<strong>            'kanji' =&gt; '\u4eac\u90fd'<\/strong>\r\n<strong>        ]<\/strong>\r\n<strong>    ]<\/strong>\r\n<strong>];<\/strong>\r\n<strong>echo array_get($array, 'japan.tokyo.kanji'); \/\/ \u6771\u4eac<\/strong><\/pre>\n<p>array_get() \u3082\u300c\u30c9\u30c3\u30c8\u3064\u306a\u304e\u300d\u3067\u914d\u5217\u306e\u6df1\u3044\u3068\u3053\u308d\u307e\u3067\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3093\u3067\u3001\u3088\u308a\u30b7\u30f3\u30d7\u30eb\u306b\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u304c\u3042\u308b\u30d0\u30fc\u30b8\u30e7\u30f3\u3002<\/p>\n<pre>echo <strong>array_get($array, 'japan.osaka.kanji', '\u306a\u3057');<\/strong> \/\/ \u306a\u3057<\/pre>\n<p>PHP \uff17\u304b\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u300cNull \u5408\u4f53\u6f14\u7b97\u5b50\u300d\u3082\u4f7f\u3048\u307e\u3059\u3051\u3069\u3001\u500b\u4eba\u7684\u306b<strong>array_get()<\/strong>\u306e\u65b9\u304c\u3088\u308a\u66f8\u304d\u3084\u3059\u3044\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><strong>echo $array['japan']['kyoto']['kanji'] ?? '\u306a\u3057';<\/strong><\/pre>\n<h1>\uff17\uff0eresponse()<\/h1>\n<p>\u3053\u308c\u3082\u5fc5\u9808\u3068\u3044\u3048\u3070\u5fc5\u9808\u306a\u3093\u3067\u3059\u3051\u3069\u3001\u6614\u306f<\/p>\n<pre><strong>return \\Response::json([])<\/strong><\/pre>\n<p>\u3068\u304b\u3063\u3066\u66f8\u3044\u3066\u3044\u3066\u9762\u5012\u3060\u3063\u305f\u306e\u3067\u4eca\u56de\u306e\uff17\u9078\u306b\u52a0\u3048\u307e\u3057\u305f\u3002<\/p>\n<pre><strong>return response()-&gt;json([<\/strong>\r\n<strong>    'xxx' =&gt; 'yyy'<\/strong>\r\n<strong>]);<\/strong><\/pre>\n<p>\u3068\u3059\u308c\u3070\u3001<\/p>\n<pre><strong>{\"xxx\":\"yyy\"}<\/strong><\/pre>\n<p>\u3068\u3001json\u3067\u8fd4\u3057\u3066\u304f\u308c\u308b\u3057\u3001<\/p>\n<pre><strong>$headers = ['Content-Type' =&gt; 'test\/test'];<\/strong>\r\n<strong>return response('Hello World', 200, $headers);<\/strong><\/pre>\n<p>\u3068\u3059\u308c\u3070\u3001HTTP\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u3068\u30d8\u30c3\u30c0\u30fc\u3082\u7c21\u5358\u306b\u8a2d\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u305d\u306e\u4ed6\u306b\u3082\u6b21\u70b9\u3067\u7d50\u69cb\u4f7f\u3046\u3053\u3068\u304c\u591a\u3044\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u304c\u3042\u308b\u3093\u3067\u3001\u307e\u3068\u3081\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>str_contains()\u3000\u30fb\u30fb\u30fb\u3000\u6587\u5b57\u5217\u306b\u7279\u5b9a\u306e\u6587\u5b57\u304c\u5165\u3063\u3066\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af<\/li>\n<li>str_limit()\u3000\u30fb\u30fb\u30fb\u3000mb_strimwidth() \u3092\u7c21\u7565\u5316\u3057\u305f\u3082\u306e\u3002\u6587\u5b57\u3092\u8a70\u3081\u3066\u304f\u308c\u308b\u3002<\/li>\n<li>route()\u3000\u30fb\u30fb\u30fb\u3000\u30eb\u30fc\u30c8\u540d\u3092\u6307\u5b9a\u3059\u308b\u3068URL\u3092\u4f5c\u6210\u3057\u3066\u304f\u308c\u308b\u3002<\/li>\n<li>url()\u3000\u30fb\u30fb\u30fb\u3000URL\u3092\u4f5c\u6210\u3002<\/li>\n<li>path()\u3000\u30fb\u30fb\u30fb\u3000\u4f8b\u3048\u3070 public_path() \u3068\u304b\u3002path\u3092\u8fd4\u3057\u3066\u304f\u308c\u308b\u3093\u3067\u3001\u3053\u308c\u3082\u91cd\u5b9d\u3057\u307e\u3059\u3002<\/li>\n<li>app()\u3000\u30fb\u30fb\u30fb\u3000\u3068\u304f\u306b\u30ed\u30b1\u30fc\u30eb\u3092\u53d6\u5f97\u3059\u308b\u3068\u304d\u306a\u3069\u306b\u4f7f\u3063\u3066\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u3042\u3068\u3001\u4eca\u56de\u300c\u3053\u3093\u306a\u306e\u304c\u3042\u3063\u305f\u3093\u3060\uff01\u300d\u3068\u3044\u3046\u3082\u306e\u3092\u767a\u898b\u3057\u305f\u3093\u3067\u30e1\u30e2\u3002<\/p>\n<ul>\n<li>now()<\/li>\n<li>today()<\/li>\n<\/ul>\n<p>Carbon\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u540d\u3092\u8fd4\u3057\u3066\u304f\u308c\u308b\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u3067\u3059\u3002<br \/>\n\u4eca\u307e\u3067 <strong>new Carbon()<\/strong>\u3068\u304b\u3001<strong>Carbon::parse()<\/strong>\u3063\u3066\u66f8\u3044\u3066\u307e\u3057\u305f\u3051\u3069\u3001\u3053\u308c\u304b\u3089\u306f\u3053\u306e\uff12\u3064\u3092\u30b4\u30ea\u30b4\u30ea\u4f7f\u3063\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\uff01<\/p>\n<p>Laravel\u306f\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u3054\u3068\u306b\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u3082\u5897\u3084\u3057\u3066\u3044\u3063\u3066\u308b\u3093\u3067\u3001\u307f\u306a\u3055\u3093\u3082\u305c\u3072\u30c1\u30a7\u30c3\u30af\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3001\u3010Laravel5.6\u3011\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u76f4\u5f8c\u306b\u3084\u308b\u3053\u3068\uff13\u70b9\u306a\u3069\u3053\u3053\u306e\u6240Laravel\u306e\u8a71\u984c\u304c\u591a\u304f\u306a\u3063\u3066\u308b\u308f\u3051\u3067\u3059\u3051\u3069\u3001\u305d\u3093\u306a\u4e2d\u3001\u3075\u3068\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3092\u767a\u898b\u3057\u307e\u3057\u305f\u3002 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=320\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel\u306e\u3088\u304f\u4f7f\u3046\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\uff17\u9078\uff01&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":269,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,10],"tags":[44],"class_list":["post-320","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-php","tag-44"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=320"}],"version-history":[{"count":1,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/320\/revisions"}],"predecessor-version":[{"id":321,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/320\/revisions\/321"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/269"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}