{"id":938,"date":"2018-11-21T11:39:37","date_gmt":"2018-11-21T02:39:37","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=938"},"modified":"2018-12-06T12:41:09","modified_gmt":"2018-12-06T03:41:09","slug":"post-938","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2018\/11\/21\/post-938\/","title":{"rendered":"Laravel\uff1a\u591a\u5bfe\u591a\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u4f5c\u6210\u6642\u306e\u6ce8\u610f\u70b9"},"content":{"rendered":"<h2>Laravel\u3067\u591a\u5bfe\u591a\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u4f5c\u6210\u6642\u306e\u6ce8\u610f\u70b9<\/h2>\n<p>Laravel\u3092\u89e6\u308a\u3060\u3057\u3066\u7d041\u304b\u6708\u304c\u7d4c\u3061\u307e\u3057\u305f\u3002<br \/>\n\u305d\u306e\u9593\u306b\u5e38\u6642SSL\u5316\u306e\u70ba\u306eServer\u79fb\u52d5\u304c\u3042\u308a\u6025\u304e\u306e\u4ed5\u4e8b\u3092\u4f59\u5100\u306a\u304f\u3055\u308c\u307e\u3057\u305f\u304c\u3001\u3084\u3063\u3068Laravel\u30b7\u30b9\u30c6\u30e0\u306b\u623b\u3063\u3066\u3053\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>1\u9031\u9593\u3067\u306eEC-CUBE\u30b5\u30a4\u30c8\u69cb\u7bc9\u306f\u9811\u5f35\u3063\u305f\u3068\u81ea\u5206\u3092\u8912\u3081\u3066\u3084\u308a\u305f\u3044\u6c17\u5206\u3067\u3059\u304c\u3001\u5fc5\u8981\u306b\u8feb\u307e\u308c\u308c\u3070\u5927\u4f53\u306a\u3093\u3067\u3082\u3084\u308b\u3082\u3093\u3067\u3059\u3088\u3002<br \/>\n\u3068\u3044\u3046\u4e8b\u3067\u3001\u5fc5\u8981\u306b\u8feb\u307e\u308c\u3066\u308b\u305f\u3081\u8abf\u3079\u306a\u304c\u3089\u306a\u3093\u3068\u304b1\u65e5\u304c\u304b\u308a\u3067\u89e3\u6c7a\u3057\u305f\u591a\u5bfe\u591a\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u5099\u5fd8\u9332\u3067\u3059\u3002<\/p>\n<div class=\"pointBox\">\n<ol>\n<li>\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u306e\u540d\u79f0\u306f\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u9806\u306b\u53c2\u7167\u5143\u30c6\u30fc\u30d6\u30eb\u306e\u5358\u6570\u5f62\u3092\u30b9\u30cd\u30fc\u30af\u8a18\u6cd5\u3067\u8a18\u8f09<\/li>\n<li>\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u306b\u81ea\u52d5\u63a1\u756a\u306eid\u30ab\u30e9\u30e0\u304c\u3042\u3063\u3066\u3082OK\u3002\u300e\u53c2\u7167\u5143\u30c6\u30fc\u30d6\u30eb\u306e\u30c6\u30fc\u30d6\u30eb\u540d(\u5358\u6570)_id\u300f\u306e\u30ab\u30e9\u30e0\u306f\u5fc5\u9808<\/li>\n<li>\u53c2\u7167\u5143\u30c6\u30fc\u30d6\u30eb\u304cAs\u3001Bs\u306e\u6642\u3001\u30e2\u30c7\u30eb\u540d\u306fA.php\u3068B.php\u3068\u306a\u308b\u3002<\/li>\n<li>\u5176\u3005\u306e\u30e2\u30c7\u30eb\u306b\u306f\u30e2\u30c7\u30eb\u540d\u3068\u540c\u3058class\u540d\u3092\u4ed8\u3051\u3001\u7570\u306a\u308b\u30c6\u30fc\u30d6\u30eb\u540d\u306e\u5358\u6570\u5f62\u3092function\u540d\u306b\u3057\u3066\u8a2d\u7f6e\u3059\u308b<\/li>\n<li>view\u3067\u306f\u914d\u5217\u306e\u968e\u5c64\u306e\u6570\u3060\u3051@foreach\u3092\u4f7f\u3044\u5024\u3092\u53d6\u308a\u51fa\u3059<\/li>\n<\/ol>\n<\/div>\n<h3>\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u306e\u540d\u79f0\u306f\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u9806\u306b\u30b9\u30cd\u30fc\u30af\u8a18\u6cd5\u3067\u8a18\u8f09<\/h3>\n<p>alists,blists\u306e\u591a\u5bfe\u591a\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u5834\u5408\u3001\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u540d\u306f\u300ealist_blist\u300f\u3002<\/p>\n<p>\u30b0\u30b0\u308b\u3068\u300ealists_blists\u300f\u3068\u547d\u540d\u3057\u3066\u3044\u308b\u3082\u306e\u3082\u3042\u308b\u304c\u3001<a href=\"https:\/\/readouble.com\/laravel\/5.1\/ja\/eloquent-relationships.html#many-to-many\"><span class=\"markerBlue\"><strong>\u53c2\u7167\u5143\u30c6\u30fc\u30d6\u30eb\u306e\u5358\u6570\u5f62\u3092\u30b9\u30cd\u30fc\u30af\u8a18\u6cd5\u3067\u63a5\u7d9a<\/strong><\/span><\/a><span class=\"markerBlue\">\u304c<\/span><strong>\u57fa\u672c<\/strong>\u3067\u3059\u3002<\/span><\/p>\n<p>\u4e0a\u8a18\u6761\u4ef6\u306f\u660e\u793a\u7684\u306b\u6307\u5b9a\u3057\u3066\u51e6\u7406\u51fa\u6765\u308b\u306e\u3067\u5fc5\u9808\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u4f8b\u3048\u3070\u3001blists\u306e\u65b9\u304c\u89aa\u8981\u7d20\u304c\u5f37\u3044\u6642\u306a\u3069\u3001\u300eblist_alist\u300f\u306e\u65b9\u304c\u3057\u3063\u304f\u308a\u3059\u308b\u4e8b\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3046\u3044\u3046\u6642\u306b\u306f\u305d\u308c\u307b\u3069\u96e3\u3057\u304f\u306a\u304f\u5bfe\u5fdc\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">\/* model:Alist *\/\r\n&lt;?php\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Alist extends Model\r\n{\r\n    public function blist(){\r\n        return $this-&gt;belongsToMany('App\\Models\\Blist',blist_alist);\/\/\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u540d\u3092\u660e\u793a\r\n    }\r\n}<\/pre>\n<h3>\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u306b\u81ea\u52d5\u63a1\u756a\u306eid\u30ab\u30e9\u30e0\u304c\u3042\u3063\u3066\u3082OK<\/h3>\n<p>\u4e0a\u624b\u304f\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3057\u306a\u3044\u6642\u306b\u4e0a\u624b\u304f\u3044\u304b\u306a\u3044\u8981\u56e0\u306a\u306e\u3067\u306f\u3068\u7591\u3044\u307e\u3057\u305f\u304c\u3001\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5f35\u308c\u308b\u304b\u5426\u304b\u306b\u306f\u5168\u304f\u5f71\u97ff\u3092\u4e0e\u3048\u306a\u3044\u3068\u5224\u660e\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u5730\u5473\u306b\u60a9\u3093\u3067\u3057\u307e\u3063\u305f\u305f\u3081\u72ec\u7acb\u3057\u305f\u9805\u76ee\u3068\u3057\u3066\u660e\u793a\u3059\u308b\u4e8b\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true\">\/*\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\uff1aalist_blist*\/\r\n&lt;?php\r\nuse Illuminate\\Support\\Facades\\Schema;\r\nuse Illuminate\\Database\\Schema\\Blueprint;\r\nuse Illuminate\\Database\\Migrations\\Migration;\r\n\r\nclass CreateAlistBlistTable extends Migration\r\n{\r\n    public function up()\r\n    {\r\n        Schema::create('alist_blist', function (Blueprint $table) {\r\n            $table-&gt;increments('id');\r\n            $table-&gt;unsignedInteger('alist_id');\r\n            $table-&gt;foreign('blist_id')-&gt;references('id')-&gt;on('blists')-&gt;onDelete('cascade');\r\n            $table-&gt;unsignedInteger('ability_id');\r\n            $table-&gt;foreign('alist_id')-&gt;references('id')-&gt;on('alists')-&gt;onDelete('cascade');\r\n            $table-&gt;integer('fragment');\r\n            $table-&gt;timestamps();\r\n        });\r\n    }\r\n    public function down()\r\n    {\r\n        Schema::dropIfExists('alist_blist');\r\n    }\r\n}<\/pre>\n<h3>\u300e\u53c2\u7167\u5143\u30c6\u30fc\u30d6\u30eb\u306e\u30c6\u30fc\u30d6\u30eb\u540d(\u5358\u6570)_id\u300f\u306e\u30ab\u30e9\u30e0\u306f\u5fc5\u9808<\/h3>\n<p>\u3053\u3053\u3082\u660e\u793a\u7684\u306b\u51e6\u7406\u3067\u304d\u307e\u3059\u304c\u3001\u4f5c\u6210\u3057\u3066\u3044\u3066\u5b9f\u611f\u3057\u305f\u306e\u306f\u300e\u547d\u540d\u898f\u5236\u306b\u6cbf\u3063\u3066\u66f8\u3044\u305f\u65b9\u304c\u304b\u306a\u308a\u697d\u300f\u3068\u3044\u3046\u4e8b\u3067\u3059\u3002<\/p>\n<p>\u547d\u540d\u898f\u5236\u306b\u6cbf\u3063\u3066\u8a18\u8f09\u3057\u305f\u5834\u5408\u3001\u6b21\u306e\u3088\u3046\u306a\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3ID\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>Table\uff1aalists.id \u3092\u683c\u7d0d\u3059\u308b\u30ab\u30e9\u30e0 alist_id<\/li>\n<li>Table\uff1ablists.id \u3092\u683c\u7d0d\u3059\u308b\u30ab\u30e9\u30e0 blist_id<\/li>\n<\/ul>\n<p>\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u3067\u306f\u3053\u306e2\u3064\u306e\u30ab\u30e9\u30e0\u304c\u5fc5\u9808\u3067\u3059\u3002<\/p>\n<h3>\u53c2\u7167\u5143\u30c6\u30fc\u30d6\u30eb\u304cAs\u3001Bs\u306e\u6642\u3001\u30e2\u30c7\u30eb\u540d\u306fA.php\u3068B.php<\/h3>\n<p>\u3053\u308c\u3082\u547d\u540d\u898f\u5236\u306b\u6cbf\u3063\u3066\u8a18\u8f09\u3059\u308b\u3068\u697d\u306a\u30d1\u30fc\u30c8\u3067\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u300eTable\uff1aalist\u300f\u300eTable\uff1ablists\u300f\u3092\u4f8b\u306b\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>Table\uff1aalists\u3092\u8ef8\u3068\u3059\u308b\u30e2\u30c7\u30eb\u540d\uff1aAlist<\/li>\n<li>Table\uff1ablists\u3092\u8ef8\u3068\u3059\u308b\u30e2\u30c7\u30eb\u540d\uff1aBlist<\/li>\n<\/ul>\n<h3>\u30e2\u30c7\u30ebclass\u540d\u306f\u30e2\u30c7\u30eb\u540d\u3068\u540c\u3058\u540d\u524d\u3092\u4ed8\u3051\u308b<\/h3>\n<p>\u30c6\u30fc\u30d6\u30eb\u540d\u3092\u660e\u793a\u7684\u306b\u6307\u793a\u3057\u8a18\u8f09\u3057\u305f\u5834\u5408\u306f\u305d\u306e\u540d\u79f0\uff08\u30e2\u30c7\u30eb\u540d\uff1aAlists\u306e\u5834\u5408\u3001class\u540d\uff1aAlists\uff09\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u547d\u540d\u898f\u5236\u306b\u6cbf\u3063\u305f\u8a18\u8f09\u306e\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u30e2\u30c7\u30eb Alist\u306eclass\u540d\uff1aAlist<\/li>\n<li>\u30e2\u30c7\u30eb Blist\u306eclass\u540d\uff1aBlist<\/li>\n<\/ul>\n<h3>\u30e2\u30c7\u30ebfunction\u540d\u306b\u306f\u30e2\u30c7\u30eb\u540d\u3068\u7570\u306a\u308b\u30c6\u30fc\u30d6\u30eb\u540d\u306e\u5358\u6570\u5f62\u3092\u4ed8\u3051\u308b<\/h3>\n<ul>\n<li>\u30e2\u30c7\u30eb Alist\u306efunction\u540d\uff1aBlist<\/li>\n<li>\u30e2\u30c7\u30eb Blist\u306efunction\u540d\uff1aAlist<\/li>\n<\/ul>\n<p>\u5177\u4f53\u7684\u306b\u306f\u4e0b\u8a18\u30b3\u30fc\u30c9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">\/* \u30e2\u30c7\u30eb\u540d\uff1aAlist *\/\r\n&lt;?php\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Alist extends Model\r\n{\r\n    public function blist(){\r\n        return $this-&gt;belongsToMany('App\\Models\\Blist');\r\n    }\r\n}<\/pre>\n<pre class=\"lang:default decode:true\">\/* Blist *\/\r\n&lt;?php\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Blist extends Model\r\n{\r\n    public function Alist(){\r\n        return $this-&gt;belongsToMany('App\\Models\\Alist')\r\n    }\r\n}<\/pre>\n<h3>view\u3067\u306f\u914d\u5217\u306e\u968e\u5c64\u306e\u6570\u3060\u3051@foreach\u3092\u4f7f\u3044\u5024\u3092\u53d6\u308a\u51fa\u3059<\/h3>\n<p>\u591a\u5bfe\u591a\u3067\u4f5c\u6210\u3057\u305f\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306f1\u3064\u306e\u30ab\u30e9\u30e0\u306b\u8907\u6570\u306e\u5024\u304c\u5165\u308b\u3010\u5165\u308c\u5b50\u69cb\u9020\u3011\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u3053\u306e\u53d6\u308a\u51fa\u3057\u306b\u4e88\u60f3\u5916\u306e\u82e6\u6226\u3002<\/p>\n<p>\u3088\u304f\u8003\u3048\u308c\u3070PHP\u306e\u591a\u6b21\u5143\u914d\u5217\u306a\u306e\u3067\u300e@foreach\u300f\u3092\u6b21\u5143\u6570\u3060\u3051\u5b9f\u884c\u3059\u308b\u306e\u306f\u5f53\u305f\u308a\u524d\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u524d\u6bb5\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u304c\u51fa\u6765\u3066\u3044\u306a\u3044\u306e\u3067\u306f\u3068\u305d\u3063\u3061\u3070\u304b\u308a\u898b\u3066\u305f\u3093\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u304a\u9670\u3067\u591a\u5bfe\u591a\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306epivot\u306e\u52d5\u4f5c\u307e\u3067\u691c\u8a3c\u3067\u304d\u307e\u3057\u305f\u304c\u6642\u9593\u304c\u639b\u304b\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<br \/>\n\u7121\u77e5\u306f\u7f6a\u3067\u3059\u306d\u3002<\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>\u524d\u56de\u306eLaravel\u8a18\u4e8b\u3067\u306f\u547d\u540d\u898f\u5236\u306b\u3064\u3044\u3066\u8a18\u8f09\u3057\u307e\u3057\u305f\u304c\u3001\u3053\u306e\u30eb\u30fc\u30eb\u3092\u4f7f\u3046\u3068\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306f\u8d85\u7c21\u5358\u3067\u3057\u305f\u3002<\/p>\n<p>\u305f\u3060\u3001Laravel\u304c\u52dd\u624b\u306b\u3084\u3063\u3066\u304f\u308c\u308b\u3053\u3068\u306a\u306e\u3067\u9593\u9055\u3044\u63a2\u3057\u306f\u307e\u3060\u6163\u308c\u305fSQL\u306e\u8a18\u8ff0\u306e\u65b9\u304c\u65e9\u3044\u3068\u3044\u3046\u5b9d\u306e\u6301\u3061\u8150\u308c\u72b6\u614b\u3002<\/p>\n<p>\u307e\u3060\u6016\u3044\u306e\u3067\u672c\u4e38\u306e\u5546\u54c1\u30c7\u30fc\u30bf\u306f\u89e6\u3089\u305a\u5468\u8fba\u306eDB\u3092\u69cb\u7bc9\u3057\u306a\u304c\u3089\u9032\u3081\u3066\u3044\u3053\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel\u3067\u591a\u5bfe\u591a\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u4f5c\u6210\u6642\u306e\u6ce8\u610f\u70b9 Laravel\u3092\u89e6\u308a\u3060\u3057\u3066\u7d041\u304b\u6708\u304c\u7d4c\u3061\u307e\u3057\u305f\u3002 \u305d\u306e\u9593\u306b\u5e38\u6642SSL\u5316\u306e\u70ba\u306eServer\u79fb\u52d5\u304c\u3042\u308a\u6025\u304e\u306e\u4ed5\u4e8b\u3092\u4f59\u5100\u306a\u304f\u3055\u308c\u307e\u3057\u305f\u304c\u3001\u3084\u3063\u3068Laravel\u30b7\u30b9\u30c6\u30e0\u306b\u623b\u3063\u3066\u3053 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":50,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","_lightning_design_setting":[],"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"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},"jetpack_post_was_ever_published":false},"categories":[34],"tags":[153,99,98,53,49,45],"class_list":["post-938","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-memorandum","tag-laravel","tag-mysql","tag-php","tag-53","tag-49","tag-45"],"veu_head_title_object":{"title":"","add_site_title":""},"jetpack_publicize_connections":[],"jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/qol-kk.com\/wp2\/wp-content\/uploads\/2018\/08\/interface3.jpg","_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/938","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=938"}],"version-history":[{"count":0,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/938\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/50"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}