{"id":1190,"date":"2019-04-12T12:10:11","date_gmt":"2019-04-12T03:10:11","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=1190"},"modified":"2019-04-12T12:10:11","modified_gmt":"2019-04-12T03:10:11","slug":"post-1190","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2019\/04\/12\/post-1190\/","title":{"rendered":"Laravel\uff1a\u53d6\u5f97\u3057\u305f\u914d\u5217\u30922\u5217\u306b\u4e26\u3079\u308b\u65b9\u6cd5"},"content":{"rendered":"<h2>Laravel\uff1a\u53d6\u5f97\u3057\u305f\u914d\u5217\u30922\u5217\u306b\u4e26\u3079\u308b\u65b9\u6cd5<\/h2>\n<p>Web\u30ab\u30bf\u30ed\u30b0\u3092\u4f5c\u308b\u6642\u306a\u30691\u5217\u306b\u8907\u6570\u500b\u306e\u914d\u5217\u3092\u7d0d\u3081\u305f\u3044\u6642\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u76f4\u6253\u3061PHP\u306e\u6642\u306f\u3010 array_chunk() \u3011\u3092\u4f7f\u3048\u3070\u4e00\u767a\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001Laravel\u3067\u4f7f\u304a\u3046\u3068\u3057\u305f\u6642\u554f\u984c\u304c\u751f\u3058\u307e\u3057\u305f\u3002<\/p>\n<p><span class=\"markerBlue\"><strong>array_chunk()\u4f7f\u3046\u305f\u3081\u306b\u306f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u6e96\u5099\u304c\u5fc5\u8981\uff01<\/strong><\/span><\/p>\n<p>Laravel\u306b\u6163\u308c\u3066\u304d\u3066\u3057\u307e\u3063\u305f\u305f\u3081\u3001View\u5074\u3067\u95a2\u9023\u30c7\u30fc\u30bf\u3092\u53d6\u308b\u4e8b\u304c\u591a\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<div class=\"borderBox\">optional($hoge-&gt;hogehoge)-&gt;hagehage<\/div>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067View\u3067\u56de\u305b\u3066\u3057\u307e\u3046\u306e\u3067\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067SQL\u66f8\u304f\u4e8b\u304c\u6fc0\u6e1b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u76f4\u63a5PHP\u66f8\u3051\u3070\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u6298\u89d2\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002view\u306b &lt;?php\u3000?&gt; \u306a\u3093\u3066\u66f8\u304d\u305f\u304f\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3068\u8a00\u3046\u3053\u3068\u3067\u3001Controller\u3067\u53d6\u5f97\u3057\u305f\u914d\u5217\u3092View\u5074\u30672\u5217\u306e\u30ea\u30b9\u30c8\u306b\u3059\u308b\u305f\u3081\u8abf\u3079\u305f\u7d50\u679c\u3092\u5099\u5fd8\u9332\u3068\u3057\u3066\u8a18\u3057\u307e\u3059\u3002<\/p>\n<h3>Laravel\u306b\u306fforeach()\u3092\u30b5\u30dd\u30fc\u30c8\u3059\u308b$loop\u95a2\u6570\u304c\u3042\u308b<\/h3>\n<p>Laravel5.3\u304b\u3089\u5b9f\u88c5\u3055\u308c\u305f\u6a5f\u80fd\u3067\u3001\u4e3b\u306b\u30eb\u30fc\u30d7\u306e\u56de\u6570\u306a\u3069\u306e\u60c5\u5831\u3092\u3064\u304b\u3055\u3069\u308b\u30d1\u30fc\u30c4\u306e\u69d8\u3067\u3059\u3002<\/p>\n<p>\u7d50\u8ad6\u3092\u8a00\u3048\u3070\u300c\u3053\u3044\u3064\u304c\u4f7f\u3048\u308b\uff01\u300d<\/p>\n<div class=\"borderBox\">\n<ol>\n<li>$loop-&gt;index\uff1a\u73fe\u5728\u306e\u30eb\u30fc\u30d7\u756a\u53f7 \u203b\u521d\u671f\u5024\uff1d0<\/li>\n<li>$loop-&gt;iteration\uff1a\u73fe\u5728\u306e\u7e70\u308a\u8fd4\u3057\u56de\u6570 \u203b\u521d\u671f\u5024\uff1d1<\/li>\n<li>$loop-&gt;remaining\uff1a\u7e70\u8fd4\u3057\u306e\u6b8b\u308a\u56de\u6570<\/li>\n<li>$loop-&gt;count\uff1a\u30eb\u30fc\u30d7\u3057\u3066\u3044\u308b\u914d\u5217\u306e\u7dcf\u30a2\u30a4\u30c6\u30e0\u6570<\/li>\n<li>$loop-&gt;first\uff1a\u30eb\u30fc\u30d7\u306e\u6700\u521d\u304b<\/li>\n<li>$loop-&gt;last\uff1a\u30eb\u30fc\u30d7\u306e\u6700\u5f8c\u304b<\/li>\n<li>$loop-&gt;depth\uff1a\u73fe\u5728\u306e\u30eb\u30fc\u30d7\u306e\u30cd\u30b9\u30c8\u30ec\u30d9\u30eb<\/li>\n<li>$loop-&gt;parent\uff1a\u30eb\u30fc\u30d7\u304c\u30cd\u30b9\u30c8\u3057\u3066\u3044\u308b\u5834\u5408\u306e\u89aa\u30eb\u30fc\u30d7\u6570<\/li>\n<\/ol>\n<\/div>\n<p>\u30a2\u30a4\u30c6\u30e0\u30922\u5217\u306b\u4e26\u3079\u305f\u3044\u8a33\u3060\u304b\u3089\u3001$loop-&gt;iteration \u3092\u4f7f\u3063\u3066\u5076\u6570\u3068\u5947\u6570\u3092\u5224\u5225\u3059\u308c\u3070\u5b9f\u88c5\u3067\u304d\u305d\u3046\u3067\u3059\u3002<\/p>\n<h3>&lt;table&gt;\u3067\u914d\u5217\u30922\u5217\u306e\u30ea\u30b9\u30c8\u306b\u3059\u308b<\/h3>\n<p>$loop-&gt;count\u3067\u7dcf\u6570\u51fa\u3057\u3066\u3001\u00f72\u3057\u3066$loop-&gt;remaining\u3067\u534a\u5206\u306b\u6765\u305f\u3089&lt;div style='float:left;width:50%' &gt;\u3067\u982d\u4f5c\u308b\u3068\u3044\u3046\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u3002<br \/>\n\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u4eca\u56de\u306f\u7c21\u5358\u306a\u65b9\uff08table\uff09\u3067\u4f5c\u6210\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">&lt;table&gt;\r\n    &lt;tr&gt;\r\n        &lt;th&gt;SEO\u30ef\u30fc\u30c9&lt;\/th&gt;\r\n        &lt;th&gt;\u96c6\u5ba2PT&lt;\/th&gt;\r\n        &lt;th&gt;\u30b5\u30b8\u30a7\u30b9\u30c8PT&lt;\/th&gt;\r\n        &lt;th&gt;NG\u30c1\u30a7\u30c3\u30af&lt;\/th&gt;\r\n        &lt;th&gt;SEO\u30ef\u30fc\u30c9&lt;\/th&gt;\r\n        &lt;th&gt;\u96c6\u5ba2PT&lt;\/th&gt;\r\n        &lt;th&gt;\u30b5\u30b8\u30a7\u30b9\u30c8PT&lt;\/th&gt;\r\n        &lt;th&gt;NG\u30c1\u30a7\u30c3\u30af&lt;\/th&gt;\r\n    &lt;\/tr&gt;\r\n    @foreach($seowords as $word)\r\n        @if($loop-&gt;iteration %2 !=0)\r\n            &lt;tr&gt;\r\n        @endif\r\n        &lt;td&gt;{{$word-&gt;word}}&lt;\/td&gt;\r\n        &lt;td&gt;{{$word-&gt;count-&gt;visit}}&lt;\/td&gt;\r\n        &lt;td&gt;{{$word-&gt;count-&gt;suggest}}&lt;\/td&gt;\r\n        &lt;td&gt;\r\n            @if((optional($word-&gt;nglist)-&gt;ng_check)===1)\r\n                &lt;input type='checkbox' name='ng_check' value=\"1\" checked&gt;\r\n            @elseif((optional($word-&gt;nglist)-&gt;ng_check)===0)\r\n                &lt;input type='checkbox' name='ng_check' value=\"1\"&gt;\r\n            @else\r\n                \u2015\r\n            @endif\r\n        &lt;\/td&gt;\r\n        @if($loop-&gt;iteration %2 ==0)\r\n            &lt;\/tr&gt;\r\n        @endif\r\n    @endforeach\r\n&lt;\/table&gt;<\/pre>\n<h3>\u89e3\u8aac\u306e\u3088\u3046\u306a\u3082\u306e<\/h3>\n<p>\u5947\u6570\u306e\u6642\u306b&lt;tr&gt;\u3092\u66f8\u3044\u3066\u3001\u5076\u6570\u306e\u6642\u306b&lt;\/tr&gt;\u3092\u66f8\u3051\u30701\u884c\u306b2\u3064\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u542b\u3093\u3060\u30c6\u30fc\u30d6\u30eb\u304c\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>$loop-&gt;iteration\u3067\u73fe\u5728\u306e\u30eb\u30fc\u30d7\u6570\u3092\u53d6\u5f97\u3067\u304d\u308b\u306e\u3067\u3001\u3053\u3044\u3064\u304c\u5076\u6570\u304b\u5947\u6570\u304b\u3092\u5224\u65ad\u3057\u3066\u6307\u793a\u3059\u308c\u3070\u671b\u307f\u306e\u5f62\u306f\u51fa\u6765\u4e0a\u308b\u8a33\u3067\u3059\u3002<\/p>\n<p>\u25a0\u5947\u6570\u306e\u6642&lt;tr&gt;\u3092\u66f8\u304f<\/p>\n<pre class=\"lang:default decode:true\">        @if($loop-&gt;iteration %2 !=0)\r\n            &lt;tr&gt;\r\n        @endif<\/pre>\n<p>\u25a0\u5076\u6570\u306e\u6642&lt;\/tr&gt;\u3092\u66f8\u304f<\/p>\n<pre class=\"lang:default decode:true\">        @if($loop-&gt;iteration %2 ==0)\r\n            &lt;\/tr&gt;\r\n        @endif<\/pre>\n<h3>$loop\u3092\u4f7f\u3063\u305f\u65b9\u6cd5\u306f\u300e\u30ab\u30bf\u30ed\u30b0\u30ea\u30b9\u30c8\u300f\u306a\u3069\u306b\u6d41\u7528\u3067\u304d\u308b<\/h3>\n<p>\u3053\u306e\u65b9\u6cd5\u3092\u4f7f\u3048\u3070\u3001\u5546\u54c1\u306e\u753b\u50cf\u30925\u500b\u4e26\u3079\u305f\u30ab\u30bf\u30ed\u30b0\u30ea\u30b9\u30c8\u306a\u3069\u3092\u7c21\u5358\u306b\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3042\u3001\u3067\u3082catalog\u306e\u5834\u5408\u306f\u30d5\u30ed\u30fc\u30c8\u4f7f\u3063\u3066&lt;div&gt;\u4e26\u3079\u305f\u65b9\u304c\u65e9\u3044\u3067\u3059\u306d\u3002<\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>Laravel\u306b\u306f\u4fbf\u5229\u306a\u95a2\u6570\u304c\u3044\u304f\u3064\u3082\u7528\u610f\u3055\u308c\u3066\u3044\u3066\u3001\u4f7f\u3044\u65b9\u6b21\u7b2c\u3067\u3044\u308d\u3044\u308d\u306a\u4e8b\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u300carray_chunk()\u304c\u4f7f\u3048\u306a\u3044\uff01\u300d\u3068\u601d\u3063\u305f\u6642\u306f\u982d\u75db\u304f\u306a\u308a\u307e\u3057\u305f\u304c\u3001\u3055\u3059\u304c\u30e9\u30e9\u30d9\u30eb\u3055\u3093\u3001\u5f15\u304d\u51fa\u3057\u306f\u6f64\u6ca2\u3067\u3057\u305f\u3002<\/p>\n<p>\u4fbf\u5229\u3060\u306a\u3041\u3001\u3084\u3063\u3071\u308a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel\uff1a\u53d6\u5f97\u3057\u305f\u914d\u5217\u30922\u5217\u306b\u4e26\u3079\u308b\u65b9\u6cd5 Web\u30ab\u30bf\u30ed\u30b0\u3092\u4f5c\u308b\u6642\u306a\u30691\u5217\u306b\u8907\u6570\u500b\u306e\u914d\u5217\u3092\u7d0d\u3081\u305f\u3044\u6642\u304c\u3042\u308a\u307e\u3059\u3002 \u76f4\u6253\u3061PHP\u306e\u6642\u306f\u3010 array_chunk() \u3011\u3092\u4f7f\u3048\u3070\u4e00\u767a\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001Laravel\u3067\u4f7f\u304a\u3046 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":944,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"vkexunit_cta_each_option":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[34],"tags":[374,373,54,153,99,98,53,58,45],"class_list":["post-1190","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-memorandum","tag-loop","tag-array_chunk","tag-html","tag-laravel","tag-mysql","tag-php","tag-53","tag-58","tag-45"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/qol-kk.com\/wp2\/wp-content\/uploads\/2018\/11\/laravel_logo.png","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/1190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/comments?post=1190"}],"version-history":[{"count":1,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/1190\/revisions"}],"predecessor-version":[{"id":1191,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/1190\/revisions\/1191"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/944"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=1190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=1190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=1190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}