{"id":6020,"date":"2020-03-04T19:25:34","date_gmt":"2020-03-04T10:25:34","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=6020"},"modified":"2020-03-12T19:01:24","modified_gmt":"2020-03-12T10:01:24","slug":"laravel-7-x%e3%81%ae%e6%96%b0%e3%83%ab%e3%83%bc%e3%83%88%e6%a9%9f%e8%83%bd%ef%bc%88%e3%83%a2%e3%83%87%e3%83%ab%e3%83%bb%e3%83%90%e3%82%a4%e3%83%b3%e3%83%87%e3%82%a3%e3%83%b3%e3%82%b0%ef%bc%89%e5%ae%9f","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=6020","title":{"rendered":"Laravel 7.x\u306e\u65b0\u30eb\u30fc\u30c8\u6a5f\u80fd\uff08\u30e2\u30c7\u30eb\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\uff09\u5b9f\u4f8b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u524d\u56de\u8a18\u4e8b\u300c<a href=\"https:\/\/blog.capilano-fw.com\/?p=5993\" target=\"_blank\" rel=\"noopener noreferrer\">\u65b0\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u6a5f\u80fd\uff01\u5b9f\u4f8b<\/a>\u300d\u3067\u306f\u3001<code>Laravel 7.x<\/code>\u306e\u65b0\u6a5f\u80fd\u306e\u4e2d\u304b\u3089\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u3064\u3044\u3066\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u4eca\u56de\u306f\u3082\u3046\u3072\u3068\u3064\u300c<strong>\u3061\u3087\u3063\u3068\u5730\u5473\u3060\u3051\u3069\u524d\u304b\u3089\u6b32\u3057\u304b\u3063\u305f<\/strong>\u300d\u6a5f\u80fd\u306b\u3064\u3044\u3066\u5b9f\u4f8b\u3092\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u306e\u5185\u5bb9\u3068\u306f\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u30eb\u30fc\u30c8\u306e\u65b0\u3057\u3044\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u65b9\u6cd5<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001<code>Laravel<\/code>\u3067\u306f\u30eb\u30fc\u30c8\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066<code>http:\/\/your-site.test\/user\/1<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001\u81ea\u52d5\u7684\u306b<code>ID<\/code>\u304c<code>1<\/code>\u306e\u30c7\u30fc\u30bf\u3092User\u30e2\u30c7\u30eb\u304b\u3089\u53d6\u5f97\u3057\u3066\u304f\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>use \\App\\User;\r\n\r\nRoute::get('user\/<strong>{user}<\/strong>', function(<strong>User $user<\/strong>) { \/\/ DB\u304b\u3089\u30c7\u30fc\u30bf\u3092\u81ea\u52d5\u53d6\u5f97\r\n\r\n    \/\/\r\n\r\n});<\/pre>\n<p>\u3053\u308c\u306f\u300c<strong>\u30e2\u30c7\u30eb\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0<\/strong>\u300d\u3068\u547c\u3070\u308c\u308b\u3082\u306e\u3067\u30b3\u30fc\u30c9\u91cf\u304c\u5c11\u306a\u304f\u3066\u6e08\u3080<code>Laravel<\/code>\u306e\u5f37\u529b\u306a\u6a5f\u80fd\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u3053\u306e\u6a5f\u80fd\u306b\u4ee5\u524d\u304b\u3089\u300c\u3042\u308c\u3070\u3044\u3044\u306e\u306b\u306a\u30fb\u30fb\u30fb\u300d\u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u306f\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">ID\u4ee5\u5916\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3092\u3057\u305f\u3044<\/strong><\/p>\n<p>\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u306f\u4eca\u56de\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3067\u3053\u306e\u8981\u671b\u304c\u5b9f\u88c5\u3055\u308c\u307e\u3057\u305f\u306e\u3067\u4f7f\u3044\u65b9\u3092\u3054\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\uff08\u307e\u305f\u3001\u3053\u308c\u306b\u95a2\u9023\u3057\u305f\u4fbf\u5229\u6a5f\u80fd\u304c\u8ffd\u52a0\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u5f8c\u3067\u5408\u308f\u305b\u3066\u3054\u7d39\u4ecb\u3057\u307e\u3059\uff09<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u306e\u304a\u5f79\u306b\u7acb\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3566 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1.png\" alt=\"\" width=\"306\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1.png 306w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1-287x300.png 287w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/><\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 7.x<\/p>\n<h1>DB\u30c6\u30fc\u30d6\u30eb\u306e\u6e96\u5099<\/h1>\n<p>\u3053\u3053\u304b\u3089\u3054\u7d39\u4ecb\u3059\u308b\u5185\u5bb9\u3067\u5fc5\u8981\u306aDB\u30c6\u30fc\u30d6\u30eb\u306f\u4ee5\u4e0b\u306e\uff12\u3064\u3067\u3059\u3002<\/p>\n<ul>\n<li>users\u3000\u30fb\u30fb\u30fb\u3000\u30b5\u30a4\u30c8\u306e\u30e6\u30fc\u30b6\u30fc<\/li>\n<li>posts\u3000\u30fb\u30fb\u30fb\u3000\u30e6\u30fc\u30b6\u30fc\u304c\u6295\u7a3f\u3057\u305f\u5185\u5bb9<\/li>\n<\/ul>\n<p>\u305d\u3057\u3066\u3001\u30c6\u30fc\u30d6\u30eb\u306e\u5185\u5bb9\u306f\u3053\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6021\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_1.png\" alt=\"\" width=\"358\" height=\"315\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_1.png 358w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_1-300x264.png 300w\" sizes=\"auto, (max-width: 358px) 100vw, 358px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6022\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_2.png\" alt=\"\" width=\"349\" height=\"294\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_2.png 349w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_2-300x253.png 300w\" sizes=\"auto, (max-width: 349px) 100vw, 349px\" \/><\/p>\n<p>\u306a\u304a\u3001<code>posts<\/code>\u30c6\u30fc\u30d6\u30eb\u306e<code>slug<\/code>\u306f\u4ed6\u306e\u30c7\u30fc\u30bf\u3068\u91cd\u8907\u300c<strong>\u3057\u306a\u3044<\/strong>\u300dID\u306e\u3088\u3046\u306a\u3082\u306e\u3068\u3057\u3066\u5229\u7528\u3057\u307e\u3059\u3002\u307e\u305f<code>user_id<\/code>\u306f<code>users<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u5916\u90e8\u30ad\u30fc\u3092\u901a\u3057\u3066\u9023\u643a\u3092\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nuse Illuminate\\Database\\Migrations\\Migration;\r\nuse Illuminate\\Database\\Schema\\Blueprint;\r\nuse Illuminate\\Support\\Facades\\Schema;\r\n\r\nclass CreatePostsTable extends Migration\r\n{\r\n    \/**\r\n     * Run the migrations.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function up()\r\n    {\r\n        Schema::create('posts', function (Blueprint $table) {\r\n            $table-&gt;id();\r\n            $table-&gt;unsignedBigInteger('user_id');\r\n            $table-&gt;string('title');\r\n            $table-&gt;text('content');\r\n            <strong>$table-&gt;string('slug');<\/strong> \/\/ \u91cd\u8907\u3057\u306a\u3044\u6587\u5b57\u5217\r\n            $table-&gt;timestamps();\r\n\r\n            <strong>$table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users');<\/strong>\r\n<strong>            $table-&gt;unique('slug');<\/strong>\r\n        });\r\n    }\r\n\r\n    \/**\r\n     * Reverse the migrations.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function down()\r\n    {\r\n        Schema::dropIfExists('posts');\r\n    }\r\n}<\/pre>\n<p>\u3067\u306f\u3001DB\u30c6\u30fc\u30d6\u30eb\u306e\u6e96\u5099\u304c\u3067\u304d\u305f\u3089\u5b9f\u969b\u306b<code>ID<\/code>\u4ee5\u5916\u3067\u30e2\u30c7\u30eb\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u65b9\u6cd5\u3092\u307f\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<h1 id=\"custom_pk\">ID\u4ee5\u5916\u3067\u30e2\u30c7\u30eb\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u65b9\u6cd5<\/h1>\n<h2>\u4e00\u756a\u30b7\u30f3\u30d7\u30eb\u306a\u65b9\u6cd5<\/h2>\n<p>\u3067\u306f\u3001\u4e00\u756a\u30b7\u30f3\u30d7\u30eb\u306b<code>posts<\/code>\u306e<code>slug<\/code>\u3092\u4f7f\u3063\u3066\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<br \/>\n\u5b9f\u969b\u306e\u4f8b\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Route::get('post\/<strong>{post:slug}<\/strong>', function(\\App\\Post $post) {\r\n\r\n    \/\/\r\n\r\n});<\/pre>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u30eb\u30fc\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u4f8b\u3048\u3070\u3001\u300chttp:\/\/your-site.test\/post\/<strong>post-5<\/strong>\u300d\u306a\u3069\u306e\u3088\u3046\u306aURL\u306b\u306a\u308a\u3001\u305d\u306e\u5834\u5408<code>slug<\/code>\u304c<code>post-5<\/code>\u306e\u3082\u306e\u304c\u81ea\u52d5\u7684\u306b\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6023\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_3.png\" alt=\"\" width=\"633\" height=\"365\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_3.png 633w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_3-300x173.png 300w\" sizes=\"auto, (max-width: 633px) 100vw, 633px\" \/><\/p>\n<h2>\u30e2\u30c7\u30eb\u306e\u4e2d\u3067\u6307\u5b9a\u3059\u308b<\/h2>\n<p>\u30eb\u30fc\u30c8\u3067\u76f4\u63a5\u6307\u5b9a\u3059\u308b\u65b9\u6cd5\u304c\u4e00\u756a\u304a\u624b\u8efd\u3067\u3059\u304c\u3001\u3082\u3057\u6307\u5b9a\u3059\u308b\u30eb\u30fc\u30c8\u304c\u591a\u3044\u5834\u5408<code>:<\/code>\u4ee5\u964d\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u6307\u5b9a\u3092\u5fd8\u308c\u3066\u3057\u307e\u3063\u305f\u308a\u3001\u4f55\u5ea6\u3082\u66f8\u304f\u306e\u304c\u3081\u3093\u3069\u3046\u306b\u306a\u308b\u3053\u3068\u3082\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u5834\u5408\u306f\u3001\u30e2\u30c7\u30eb\u5185\u3067\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306e\u30bf\u30fc\u30b2\u30c3\u30c8\u306e\u521d\u671f\u5024\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u5148\u307b\u3069\u306e<code>Post<\/code>\u30c6\u30fc\u30d6\u30eb\u3067\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Post extends Model\r\n{\r\n    <strong>public function getRouteKeyName()<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        return 'slug'; \/\/ \u30e2\u30c7\u30eb\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306b\u306f slug \u3092\u4f7f\u3046<\/strong>\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u305f\u3060\u3057\u3001\u3053\u306e\u72b6\u614b\u3067\u3042\u3063\u3066\u3082\u3057\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30eb\u30fc\u30c8\u3067<code>id<\/code>\u3092\u4f7f\u3046\u3088\u3046\u6307\u5b9a\u3092\u3059\u308b\u3068\u305d\u3061\u3089\u304c\u512a\u5148\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>Route::get('post\/<strong>{post:id}<\/strong>', function(\\App\\Post $post) {\r\n\r\n    \/\/\r\n\r\n});<\/pre>\n<h1 id=\"route_combination\">\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u3092\u8003\u616e\u3057\u305f\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0<\/h1>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u304c\uff12\u3064\u5b58\u5728\u3059\u308b\u30eb\u30fc\u30c8\u304c\u3042\u308b\u3068\u3057\u307e\u3059\u3002<\/p>\n<pre>use \\App\\User;\r\nuse \\App\\Post;\r\n\r\nRoute::get('<strong>user\/{user}\/post\/{post}<\/strong>', function(User $user, Post $post) {\r\n\r\n    \/\/\r\n\r\n});<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u5b9f\u969b\u306b\u30a2\u30af\u30bb\u30b9\u3055\u308c\u308bURL\u306f\u300c<strong>http:\/\/your-site.test\/user\/1\/post\/5<\/strong>\u300d\u306e\u3088\u3046\u306b\u306a\u308a\u3001\u305d\u306e\u5834\u5408\u53d6\u5f97\u3055\u308c\u308b\u306e\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>$user\u3000\u30fb\u30fb\u30fb\u3000\u300cid\u300d\u304c\u300c1\u300d\u306e\u3082\u306e<\/li>\n<li>$post\u3000\u30fb\u30fb\u30fb\u3000\u300cid\u300d\u304c\u300c5\u300d\u306e\u3082\u306e<\/li>\n<\/ul>\n<p>\u305f\u3060\u3057\u3001\u3053\u306e\uff12\u3064\u306e\u30c7\u30fc\u30bf\u306b\u6574\u5408\u6027\u306f<strong>\u3042\u308a\u307e\u305b\u3093\u3002<\/strong><\/p>\n<p>\u3064\u307e\u308a\u3001<code>$user-&gt;id<\/code>\u3068\u3001<code>$post-&gt;user_id<\/code>\u304c\u4e00\u81f4\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u3067\u3082\u30c7\u30fc\u30bf\u304c\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3055\u308c\u3066\u51e6\u7406\u304c\u5b9f\u884c\u3055\u308c\u3066\u3057\u307e\u3046\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u4eca\u56de\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3067<code>:<\/code>\u3092\u4f7f\u3063\u3066\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u30bf\u30fc\u30b2\u30c3\u30c8\u3092\u6307\u5b9a\u3059\u308b\u3068<strong>\u6574\u5408\u6027\u3092\u3068\u308b\u51e6\u7406\u3092\u3057\u3066\u304f\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/strong><\/p>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n<p>\u306a\u304a\u3001\u3053\u306e\u6a5f\u80fd\u3092\u4f7f\u3046\u306b\u306f\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\u304c\u5fc5\u8981\u306a\u306e\u3067\u5148\u306b<code>User<\/code>\u30e2\u30c7\u30eb\u306b<code>hasMany<\/code>\u3092\u30bb\u30c3\u30c8\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\n\/\/ \u7701\u7565\r\n\r\nclass User extends Authenticatable\r\n{\r\n    \/\/ \u7701\u7565\r\n\r\n    <strong>public function posts() {<\/strong>\r\n\r\n<strong>        return $this-&gt;hasMany('App\\Post');<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u305d\u3057\u3066\u3001\u30eb\u30fc\u30c8\u306f\u3053\u3093\u306a\u5f62\u3067\u3059\u3002<\/p>\n<pre>Route::get(<strong>'user\/{user}\/post\/{post:slug}'<\/strong>, function(User $user, Post $post) {\r\n\r\n    \/\/\r\n\r\n});<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u5b9f\u969b\u306b\u30a2\u30af\u30bb\u30b9\u3055\u308c\u308bURL\u306f\u300c<strong>http:\/\/your-site.test\/user\/1\/post\/post-5<\/strong>\u300d\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u3082\u3057<code>$user-&gt;id<\/code>\u3068<code>$post-&gt;user_id<\/code>\u304c\u4e00\u81f4\u3057\u306a\u3044\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b<code>404<\/code>\u3092\u8fd4\u3059\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6024\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_4.png\" alt=\"\" width=\"206\" height=\"59\" \/><\/p>\n<p>\u3064\u307e\u308a\u3001\u4eca\u56de\u79c1\u306e\u74b0\u5883\u3067\u7528\u610f\u3057\u305f\u4ee5\u4e0b\u306e\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306e\u4e2d\u3067\u3044\u3046\u3068\u3001\u30e6\u30fc\u30b6\u30fc\u304c<code>1<\/code>\u306e\u5834\u5408\u306f<code>post-9<\/code>\u3001<code>URL<\/code>\u3067\u3044\u3046\u3068\u300c<strong>http:\/\/your-site.test\/user\/1\/post\/post-9<\/strong>\u300d\u3067\u3042\u308c\u3070\u901a\u5e38\u306e\u30a2\u30af\u30bb\u30b9\u304c\u3067\u304d\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6025\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_5.png\" alt=\"\" width=\"632\" height=\"290\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_5.png 632w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/laravel_new_model_binding_5-300x138.png 300w\" sizes=\"auto, (max-width: 632px) 100vw, 632px\" \/><\/p>\n<p>\u306a\u304a\u3001<code>slug<\/code>\u3092\u4f7f\u308f\u306a\u3044\u3051\u3069\u6574\u5408\u6027\u3082\u30ad\u30fc\u30d7\u3057\u305f\u3044\u3068\u3044\u3046\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b<code>:id<\/code>\u3092\u6307\u5b9a\u3059\u308b\u3068OK\u3067\u3059\u3002<\/p>\n<pre>Route::get('user\/{user}\/post\/<strong>{post:id}<\/strong>', function(User $user, Post $post) {\r\n\r\n    \/\/\r\n\r\n});<\/pre>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u65b0\u3057\u3044\u30e2\u30c7\u30eb\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306e\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u6a5f\u80fd\u304c\u5f79\u306b\u7acb\u3064\u306e\u306f\u3001\u5546\u54c1\u30b3\u30fc\u30c9\u3092\u4f7f\u3063\u305f\u30b7\u30b9\u30c6\u30e0\u3084\uff08\u4eca\u3082\u52b9\u679c\u304c\u3042\u308b\u306e\u304b\u306f\u7591\u554f\u3067\u3059\u304c\uff09<code>SEO<\/code>\u5bfe\u7b56\u3068\u3057\u3066<code>URL<\/code>\u306b\u6587\u5b57\u5217\u3092\u5165\u308c\u3066\u304a\u304d\u305f\u3044\u5834\u5408\u306a\u3069\u304c\u8003\u3048\u3089\u308c\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u30b3\u30fc\u30c9\u91cf\u3092\u3053\u308c\u307e\u3067\u3088\u308a\u6e1b\u3089\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u601d\u3046\u306e\u3067\u7a4d\u6975\u7684\u306b\u6d3b\u7528\u3057\u3066\u3044\u304d\u305f\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u4f7f\u3063\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3467 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_9.png\" alt=\"\" width=\"216\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_9.png 216w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_9-203x300.png 203w\" sizes=\"auto, (max-width: 216px) 100vw, 216px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u524d\u56de\u8a18\u4e8b\u300c\u65b0\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u6a5f\u80fd\uff01\u5b9f\u4f8b\u300d\u3067\u306f\u3001Laravel 7.x\u306e\u65b0\u6a5f\u80fd\u306e\u4e2d\u304b\u3089\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u3064\u3044\u3066\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002 \u305d\u3057\u3066\u3001\u4eca\u56de\u306f\u3082\u3046\u3072\u3068\u3064\u300c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=6020\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel 7.x\u306e\u65b0\u30eb\u30fc\u30c8\u6a5f\u80fd\uff08\u30e2\u30c7\u30eb\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\uff09\u5b9f\u4f8b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":6028,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-6020","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/6020","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=6020"}],"version-history":[{"count":7,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/6020\/revisions"}],"predecessor-version":[{"id":6202,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/6020\/revisions\/6202"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/6028"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}