{"id":556,"date":"2018-06-05T02:32:38","date_gmt":"2018-06-04T17:32:38","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=556"},"modified":"2020-03-12T19:55:46","modified_gmt":"2020-03-12T10:55:46","slug":"laravel%e3%81%aeroute%e3%80%81%e5%85%a8%ef%bc%96%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3%e5%ae%9f%e4%be%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=556","title":{"rendered":"Laravel\u306eRoute\u3001\u5168\uff18\u30d1\u30bf\u30fc\u30f3\u5b9f\u4f8b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u4eca\u3082\u9032\u5316\u3092\u7d9a\u3051\u308b<code>Laravel<\/code>\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u5c11\u3057\u8996\u70b9\u3092\u5909\u3048\u3066\u76f4\u63a5\u76ee\u306b\u898b\u3048\u308b\u90e8\u5206\u3067\u306f\u306a\u304f\u3001\u3088\u308a\u6839\u672c\u7684\u306a\u300c<strong>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\uff08Routing\uff09<\/strong>\u300d\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3068\u306f\u3001\u4f8b\u3048\u3070\u300c<strong>http:\/\/*****.com\/top<\/strong>\u300d\u3068\u3044\u3046URL\u3067\u30da\u30fc\u30b8\u3092\u8868\u793a\u3057\u305f\u3044\u5834\u5408\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30fb\u30d5\u30a1\u30a4\u30eb\uff08\u57fa\u672c\u7684\u306b\u306f\u3001<strong>\/routes\/web.php<\/strong>\uff09\u3067\u8272\u3005\u306a\u6761\u4ef6\u3092\u3064\u3051\u3066\u6307\u5b9a\u304c\u3067\u304d\u308b\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u4fbf\u5229\u306a\u66f8\u304d\u65b9\u3092\u77e5\u3063\u3066\u3044\u308b\u3068\u4f5c\u696d\u304c\u3088\u308a\u52b9\u7387\u5316\u3067\u304d\u308b\u3068\u601d\u3046\u306e\u3067\u305c\u3072\u6d3b\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-519 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/05\/21.png\" alt=\"\" width=\"192\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/05\/21.png 192w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/05\/21-180x300.png 180w\" sizes=\"auto, (max-width: 192px) 100vw, 192px\" \/><\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> \u301c Laravel 7.x<\/p>\n<p><strong>\u3010\u8ffd\u8a18\uff1a2020.3.12\u3011<\/strong>Laravel 7.x\u306e\u65b0\u3057\u3044\u6a5f\u80fd\u3092\uff12\u3064\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002<\/p>\n<h1>\u306f\u3058\u3081\u306b<\/h1>\n<p>\u307e\u305a\u524d\u63d0\u3068\u3057\u3066\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u300c<strong>\/routes\/web.php<\/strong>\u300d\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002\u6761\u4ef6\u306b\u3088\u3063\u3066\u305d\u306e\u4ed6\u3001api.php\u306a\u3069\u306b\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305f\u3001\u4eca\u56de\u306f\u30da\u30fc\u30b8\u3092\u8868\u793a\u3059\u308b\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u7279\u5316\u3057\u3066\u3044\u308b\u306e\u3067<strong>\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u306a\u3069\u306f\u5272\u611b\u3057\u3066\u3044\u307e\u3059\u3002<\/strong>\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/blog.capilano-fw.com\/?p=566\">Laravel\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u5b9f\u4f8b<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>HTTP\u30e1\u30bd\u30c3\u30c9\u3092\u6307\u5b9a\u3059\u308b\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/h1>\n<p>Laravel\u3067\u306f\u4ee5\u4e0b\uff16\u3064\u306eHTTP\u30e1\u30bd\u30c3\u30c9\u3092\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<ul>\n<li><strong>GET\u3000\u30fb\u30fb\u30fb\u3000\uff08\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u57fa\u672c\u7684\u306a\u3082\u306e\uff09<\/strong><\/li>\n<li><strong>POST\u3000\u30fb\u30fb\u30fb\u3000\uff08\u30c7\u30fc\u30bf\u306e\u8ffd\u52a0\u306b\u4f7f\u7528\uff09<\/strong><\/li>\n<li><strong>PUT\u3000\u30fb\u30fb\u30fb\u3000\uff08\u30c7\u30fc\u30bf\u306e\u66f4\u65b0\u306b\u4f7f\u7528\uff09<\/strong><\/li>\n<li><strong>PATCH\u3000\u30fb\u30fb\u30fb\u3000\uff08\u307b\u307cPUT\u3068\u540c\u3058\u3067\u3059\u304c\u3001\u3054\u304f\u4e00\u90e8\u3092\u66f4\u65b0\uff09<\/strong><\/li>\n<li><strong>DELETE\u3000\u30fb\u30fb\u30fb\u3000\uff08\u30c7\u30fc\u30bf\u306e\u524a\u9664\u306b\u4f7f\u7528\uff09<\/strong><\/li>\n<li><strong>OPTIONS\u3000\u30fb\u30fb\u30fb\u3000\uff08\u4f7f\u3048\u308b\u30e1\u30bd\u30c3\u30c9\u4e00\u89a7\u3092\u8868\u793a\uff09<\/strong><\/li>\n<\/ul>\n<p>\u5177\u4f53\u7684\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u300chttp:\/\/*****.com\/<strong>top<\/strong>\u300d\u3068\u3044\u3046URL\u306b\u5404\u7a2eHTTP\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u300cOK\u3067\u3059\uff01\u300d\u3068\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>Route::<strong>get<\/strong>('<strong>top<\/strong>', function(){\r\n\r\n    return 'OK\u3067\u3059!';\r\n\r\n});<\/pre>\n<pre>Route::<strong>post<\/strong>('<strong>top<\/strong>', function(){\r\n\r\n    return 'OK\u3067\u3059!';\r\n\r\n});<\/pre>\n<pre>Route::<strong>put<\/strong>('<strong>top<\/strong>', function(){\r\n\r\n    return 'OK\u3067\u3059!';\r\n\r\n});<\/pre>\n<pre>Route::<strong>patch<\/strong>('<strong>top<\/strong>', function(){\r\n\r\n    return 'OK\u3067\u3059!';\r\n\r\n});<\/pre>\n<pre>Route::<strong>delete<\/strong>('<strong>top<\/strong>', function(){\r\n\r\n    return 'OK\u3067\u3059!';\r\n\r\n});<\/pre>\n<pre>Route::<strong>options<\/strong>('<strong>top<\/strong>', function(){\r\n\r\n    return 'OK\u3067\u3059!';\r\n\r\n});<\/pre>\n<p>\u203b\u304c\u3001\u6b63\u76f4\u306a\u3068\u3053\u308d\u500b\u4eba\u7684\u306b\u306f\u300cpatch\u300d\u3068\u300coptions\u300d\u306f\u4f7f\u3063\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u307e\u305f\u3001\u8907\u6570\u306eHTTP\u30e1\u30bd\u30c3\u30c9\u3092\u6307\u5b9a\u3057\u305f\u3044\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u300c<strong>match<\/strong>\u300d\u3067\u8a31\u53ef\u3057\u305f\u3044HTTP\u30e1\u30bd\u30c3\u30c9\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>Route::<strong>match<\/strong>(<strong>['get', 'post', 'put']<\/strong>, 'top', function(){\r\n\r\n    return 'OK\u3067\u3059!';\r\n\r\n});<\/pre>\n<p>\u305d\u3057\u3066\u3001\u9006\u306b\u5168\u30e1\u30bd\u30c3\u30c9\u3067\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u3057\u305f\u3044\u5834\u5408\u306f\u300c<strong>any<\/strong>\u300d\u3067\u3059\u3002<\/p>\n<pre>Route::<strong>any<\/strong>('top', function(){\r\n\r\n    return 'OK\u3067\u3059!';\r\n\r\n});<\/pre>\n<p>\u203b\u3053\u306e\u5834\u5408\u306f\u3001GET\u3067\u3042\u308d\u3046\u304cPOST\u3067\u3042\u308d\u3046\u304c\u3001\u3069\u3093\u306a\u30a2\u30af\u30bb\u30b9\u65b9\u6cd5\u3067\u3082\u300chttp:\/\/*****.com\/<strong>top<\/strong>\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u5fc5\u8981\u306e\u306a\u3044\u7a93\u3092\u958b\u3051\u3066\u304a\u304f\u3053\u3068\u306f\u3042\u307e\u308a\u8912\u3081\u3089\u308c\u305f\u3053\u3068\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u7279\u5225\u306a\u5834\u5408\u4ee5\u5916\u306f\u4f7f\u308f\u306a\u3044\u65b9\u304c\u3044\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p><strong>\u6ce8\u610f\uff01<\/strong><\/p>\n<p>\u3061\u306a\u307f\u306b\u3001\u300cPUT\u300d\u300cPATCH\u300d\u300cDELETE\u300d\u300cOPTIONS\u300d\u306e\u5834\u5408\u306f\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3001\u3053\u308c\u3089\u306f\u5b9f\u969b\u306e\u3068\u3053\u308d\u300cPOST\u300d\u9001\u4fe1\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3068\u3044\u3046\u306e\u3082\u3001HTML\u306e&lt;form&gt;&lt;\/form&gt;\u30bf\u30b0\u304c\u3053\u308c\u3089\u306e\u5f62\u5f0f\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u306a\u3044\u304b\u3089\u306a\u3093\u3067\u3059\u306d\u3002<\/p>\n<p>\u3067\u306f\u3001Laravel\u3067\u306f\u3069\u3046\u3084\u3063\u3066\u9001\u4fe1\u5f62\u5f0f\u3092\u5224\u65ad\u3057\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u3068\u3001POST\u9001\u4fe1\u5185\u306b\u300c<strong>_method<\/strong>\u300d\u3068\u3044\u3046\u5c02\u7528\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3057\u3066\u5224\u65ad\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u3082\u3057\u30d5\u30a9\u30fc\u30e0\u3067\u300cPUT\u300d\u300cPATCH\u300d\u300cDELETE\u300d\u300cOPTIONS\u300d\u3067\u30c7\u30fc\u30bf\u9001\u4fe1\u3092\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bhidden\u5165\u529b\u3092\u4f7f\u3063\u3066\u30e1\u30bd\u30c3\u30c9\u540d\u3092\u9001\u4fe1\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre>&lt;form action=\"\/top\" <strong>method=\"POST\"<\/strong>&gt;\r\n    <strong>&lt;input type=\"hidden\" name=\"_method\" value=\"PUT\"&gt;<\/strong>\r\n&lt;\/form&gt;<\/pre>\n<p>\u3082\u3057\u304f\u306f\u3001Balde\u306e\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3092\u4f7f\u3048\u3070\u3088\u308a\u30b7\u30f3\u30d7\u30eb\u306b\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>&lt;form action=\"\/top\" <strong>method=\"POST\"<\/strong>&gt;\r\n    <strong>@method('put')<\/strong>\r\n&lt;\/form&gt;<\/pre>\n<p>\u307e\u305f\u3001Laravel\u306f\u521d\u671f\u72b6\u614b\u3067CSRF\uff08\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30ea\u30af\u30a8\u30b9\u30c8\u30d5\u30a9\u30fc\u30b8\u30a7\u30ea\uff09\u5bfe\u7b56\u304c\u65bd\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u30c8\u30fc\u30af\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3082\u5fd8\u308c\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>&lt;form action=\"\/top\" <strong>method=\"POST\"<\/strong>&gt;\r\n    <strong>@csrf<\/strong>\r\n&lt;\/form&gt;<\/pre>\n<p>\u203b\u3061\u306a\u307f\u306bCSRF\u653b\u6483\u3068\u3044\u3046\u306e\u306f\u3001\u7c21\u5358\u306b\u8a00\u3046\u3068\u300c\u30ed\u30b0\u30a4\u30f3\u3057\u305f\u307e\u307e\u4ed6\u306e\u30b5\u30a4\u30c8\u884c\u3063\u305f\u3089\u3001\u305d\u306e\u30ed\u30b0\u30a4\u30f3\u72b6\u614b\u3092\u60aa\u7528\u3059\u308b\u3088\ud83d\ude01\u300d\u653b\u6483\u3067\u3059\u3002<\/p>\n<p>\u203b\u307e\u305f\u3001\uff08\u304a\u3059\u3059\u3081\u3057\u307e\u305b\u3093\u304c\uff09\u3082\u3057<code>CSRF<\/code>\u3092\u7121\u52b9\u306b\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u300c<strong>\\App\\Http\\Middleware\\VerifyCsrfToken::class<\/strong>\u300d\u3092\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3059\u308c\u3070OK\u3067\u3059\u3002<\/p>\n<p><strong><code>\/app\/Http\/Kernel.php<\/code><\/strong><\/p>\n<pre>'web' =&gt; [\r\n    \\App\\Http\\Middleware\\EncryptCookies::class,\r\n    \\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse::class,\r\n    \\Illuminate\\Session\\Middleware\\StartSession::class,\r\n    \/\/ \\Illuminate\\Session\\Middleware\\AuthenticateSession::class,\r\n    \\Illuminate\\View\\Middleware\\ShareErrorsFromSession::class,\r\n    <strong>\\App\\Http\\Middleware\\VerifyCsrfToken::class, <\/strong>\/\/ \ud83d\udc48\u3053\u3053\r\n    \\Illuminate\\Routing\\Middleware\\SubstituteBindings::class,\r\n],<\/pre>\n<p>\u3082\u3057\u304f\u306f\u3001\u500b\u5225\u306b\u7121\u52b9\u306b\u3059\u308b\u5834\u5408\u306f\u30df\u30c9\u30eb\u30a6\u30a7\u30a2<code>VerifyCsrfToken<\/code>\u306e<code>$except<\/code>\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p><strong><code>\/app\/Http\/Middleware\/VerifyCsrfToken.php<\/code><\/strong><\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Middleware;\r\n\r\nuse Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken as Middleware;\r\n\r\nclass VerifyCsrfToken extends Middleware\r\n{\r\n    \/**\r\n     * The URIs that should be excluded from CSRF verification.\r\n     *\r\n     * @var array\r\n     *\/\r\n    <strong>protected $except = [<\/strong> \/\/ \ud83d\udc48\u3053\u3053\r\n<strong>        'stripe\/*',<\/strong>\r\n<strong>    ];<\/strong>\r\n}<\/pre>\n<h1>\u30d1\u30e9\u30e1\u30fc\u30bf\u3064\u304d\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/h1>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>http:\/\/*****.com\/item\/100<\/strong>\u300d\u3068\u3044\u3046URL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u3001URL\u5185\u306b\u3042\u308b\u300c100\u300d\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u4f8b\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Route::get('item\/<strong>{id}<\/strong>', function(<strong>$id<\/strong>){\r\n\r\n    echo 'ID\u306f\u3001'. $id .'\u3067\u3059\u3002';\r\n\r\n});<\/pre>\n<p>Laravel\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3067\u306f\u3001\u4e2d\u62ec\u5f27\uff5b\uff5d\u3067\u56f2\u307e\u308c\u305f\u90e8\u5206\u306f\u53ef\u5909\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u51e6\u7406\u3055\u308c\u3001\u81ea\u52d5\u7684\u306bfunction()\u5185\u306e\u5f15\u6570\u306b\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u3053\u306e\u4f8b\u3067\u300c<strong>http:\/\/*****.com\/item\/100<\/strong>\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-557\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/06\/l56-test-item-100.png\" alt=\"\" width=\"139\" height=\"28\" \/><\/p>\n<p>\u3068\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u3053\u306e\u5834\u5408\u3060\u3068\u5fc5\u305aID\u3092\u6307\u5b9a\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u305f\u3081\u3001\u3082\u3057\u300chttp:\/\/*****.com\/item\/\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u4f7f\u3048\u308b\u306e\u304c\u7701\u7565\u53ef\u80fd\u306a\u8a18\u8ff0\u3067\u3059\u3002<\/p>\n<pre>Route::get('item\/<strong>{id?}<\/strong>', function(<strong>$id = -1<\/strong>){\r\n\r\n    echo 'ID\u306f\u3001'. $id .'\u3067\u3059\u3002';\r\n\r\n});<\/pre>\n<p>\u3055\u3063\u304d\u3068\u4f3c\u3066\u307e\u3059\u3051\u3069\u3001<span style=\"text-decoration: underline;\">\u4e2d\u62ec\u5f27\u306e\u6700\u5f8c\u306b\u300c<strong>\uff1f<\/strong>\u300d\u30af\u30a8\u30b9\u30c1\u30e7\u30f3\u30de\u30fc\u30af\u304c\u3064\u3044\u3066\u3044\u3066\u3001\u3055\u3089\u306bfunction()\u5185\u306e\u5f15\u6570\u306b\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<p>\u3053\u308c\u3067\u3001\u30a8\u30e9\u30fc\u306f\u767a\u751f\u3057\u306a\u304f\u306a\u308a\u3001\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-558\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/06\/l56-test-item-.png\" alt=\"\" width=\"112\" height=\"33\" \/><\/p>\n<p>\u3068\u3001\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u6b21\u306b\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u5236\u9650\u3092\u304b\u3051\u305f\u3044\u5834\u5408\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u3055\u3063\u304d\u306e\u4f8b\u3060\u3068\u3001ID\u756a\u53f7\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u3082\u3001\u4f8b\u3048\u3070JavaScript\u306a\u3069\u3067\u5909\u6570\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u300chttp:\/\/*****.com\/item\/<strong>undefined<\/strong>\u300d\u3060\u3068\u304b\u3001\u3082\u3057\u304f\u306f\u521d\u671f\u5024\u304cNull\u306e\u5834\u5408\u306f\u300chttp:\/\/*****.com\/item\/<strong>null<\/strong>\u300d\u3068\u3044\u3046\u98a8\u306aURL\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u5834\u5408\u306b\u30a8\u30e9\u30fc\u3092\u5f15\u304d\u8d77\u3053\u3057\u304b\u306d\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u3053\u306e\u3088\u3046\u306a\u5834\u5408\u306b\u4f7f\u3048\u308b\u306e\u304c\u300cwhere()\u300d\u3067\u3059\u3002<br \/>\n\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>Route::get('item\/<strong>{id}<\/strong>', function($id){\r\n\r\n    echo 'ID\u306f\u3001'. $id .'\u3067\u3059\u3002';\r\n\r\n})<strong>-&gt;where('id', '[0-9]+')<\/strong>;<\/pre>\n<p>where()\u306e\u7b2c\uff12\u5f15\u6570\u306f\u6b63\u898f\u8868\u73fe\u306b\u306a\u3063\u3066\u3044\u3066\u3001\u3053\u306e\u4f8b\u3067\u306f\u300c\u6700\u4f4e\u3067\u3082\uff11\u6587\u5b57\u4ee5\u4e0a\u306e\u6570\u5b57\u300d\u304c\u5165\u3063\u3066\u304f\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u300chttp:\/\/*****.com\/item\/<strong>undefined<\/strong>\u300d\u3082\u300chttp:\/\/*****.com\/item\/<strong>null<\/strong>\u300d\u3082\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u6b63\u898f\u8868\u73fe\u3092\u5909\u66f4\u3059\u308c\u3070\u8272\u3005\u306a\u3053\u3068\u304c\u3067\u304d\u3066\u3001\u4f8b\u3048\u3070\u300c\u3042\u308b\u6587\u5b57\u5217\u3060\u3051\u3067\u8a31\u53ef\u300d\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308c\u3070\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<pre>Route::get('item\/<strong>{category}<\/strong>\/list', function($category){\r\n\r\n    echo '\u30ab\u30c6\u30b4\u30ea\u306f\u3001'. $category .'\u3067\u3059\u3002';\r\n\r\n})-&gt;where('category', '<strong>(dvd|game|audio)<\/strong>');<\/pre>\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001<\/p>\n<ul>\n<li>http:\/\/*****.com\/item\/<strong>dvd<\/strong>\/list<\/li>\n<li>http:\/\/*****.com\/item\/<strong>game<\/strong>\/list<\/li>\n<li>http:\/\/*****.com\/item\/<strong>audio<\/strong>\/list<\/li>\n<\/ul>\n<p>\u306e\uff13\u30d1\u30bf\u30fc\u30f3\u3060\u3051\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u3059\u3002<\/p>\n<h1>\u30e2\u30c7\u30eb\u3092\u81ea\u52d5\u3067\u547c\u3073\u51fa\u3059\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0<\/h1>\n<p>\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306f\u3001\u524d\u9805\u76ee\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3064\u304d\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u4f3c\u3066\u307e\u3059\u304c\u3001\u81ea\u52d5\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u8a72\u5f53\u3059\u308b\u30c7\u30fc\u30bf\u3092\u898b\u3064\u3051\u3066\u304d\u3066\u3001\u3055\u3089\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3057\u3066\u304f\u308c\u308b\u4fbf\u5229\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>http:\/\/*****.com\/user\/100<\/strong>\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308c\u3070\u3001<span style=\"text-decoration: underline;\">\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u81ea\u52d5\u3067ID\u304c100\u306e\u30c7\u30fc\u30bf\u3092\u63a2\u3057\u51fa\u3057\u3066\u304d\u3066\u3001function()\u5185\u306e\u5909\u6570\u306b\u305d\u306e\u30c7\u30fc\u30bf\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u7528\u610f\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/span><\/p>\n<p>\u3067\u306f\u3001User\u30e2\u30c7\u30eb\u3092\u4f7f\u3063\u305f\u5b9f\u969b\u306e\u4f8b\u3067\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>Route::get('user\/<strong>{user}<\/strong>', function(<strong>\\App\\User $user<\/strong>){\r\n\r\n    echo '\u540d\u524d\u306f\u3001'. $user-&gt;name .'\u3067\u3059\u3002';\r\n\r\n});<\/pre>\n<p>\u307e\u305a\u4e2d\u62ec\u5f27\uff5b\uff5d\u306e\u4e2d\u8eab\u306f\u3001\u30e2\u30c7\u30eb\u306e\u540d\u524d\uff08\u5c0f\u6587\u5b57\u3001\u5358\u6570\u5f62\uff09\u3002\u3053\u3053\u3067\u306f\u300cUser\u300d\u30e2\u30c7\u30eb\u3092\u547c\u3073\u51fa\u3059\u306e\u3067 <strong>{user}<\/strong> \u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001function()\u5185\u306f\u3001\u547c\u3073\u51fa\u3057\u305f\u3044\u30e2\u30c7\u30eb\u3092\u30bf\u30a4\u30d7\u30d2\u30f3\u30c6\u30a3\u30f3\u30b0\uff08\u578b\u306e\u5ba3\u8a00\uff09\u3067\u6307\u5b9a\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3053\u308c\u3067\u53d6\u5f97\u3067\u304d\u308b<strong>$user<\/strong>\u306f\u3001\u8a72\u5f53\u3059\u308bID\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306a\u306e\u3067\u3001\u3044\u3061\u3044\u3061\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u547c\u3073\u51fa\u3057\u3066\u304f\u308b\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre><strong>$user = \\App\\User::find($id);<\/strong><\/pre>\n<p>\u3068\u3066\u3082\u4fbf\u5229\u3067\u3059\u306d\u3002<\/p>\n<h1>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3068\u9023\u643a\u3059\u308b\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/h1>\n<p>\u3053\u3053\u307e\u3067\u306e\u30b3\u30fc\u30c9\u306f\u5168\u3066web.php\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30fb\u30d5\u30a1\u30a4\u30eb\u5185\u3067\u5b8c\u7d50\u3057\u3066\u307e\u3057\u305f\u304c\u3001\u5b9f\u969b\u306b\u306f\u5168\u3066\u306e\u30b3\u30fc\u30c9\u3092\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8ff0\u3059\u308b\u306e\u306f\u4fdd\u5b88\u4f5c\u696d\u7684\u306b\u3082\u5f97\u7b56\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u3053\u3067\u3088\u304f\u5229\u7528\u3055\u308c\u308b\u306e\u304c\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3068\u9023\u643a\u3057\u305f\u66f8\u304d\u65b9\u3067\u3059\u3002<\/p>\n<pre><strong>Route::get('route', 'HomeController@route');<\/strong><\/pre>\n<p>\u3053\u306e\u4f8b\u306f\u3001\u300c<strong>http:\/\/*****.com\/route<\/strong>\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u300c\/app\/Http\/Controllers\/HomeController.php\u300d\u306e\u4e2d\u306b\u3042\u308b\u300croute()\u300d\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3067\u306f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3068\u30a2\u30af\u30b7\u30e7\u30f3\uff08\u30e1\u30bd\u30c3\u30c9\uff09\u3092\u6307\u5b9a\u3057\u3066\u304a\u304d\u3001\u30b3\u30fc\u30c9\u306f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u4e2d\u306b\u8a18\u8ff0\u3059\u308b\u3002\u3064\u307e\u308a\u3001\u7279\u5b9a\u306e\u5f79\u5272\u3067\u5206\u5272\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306d\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3082\u3057\u968e\u5c64\u304c\u4e0b\u306e\u30d5\u30a9\u30eb\u30c0\u5185\u306b\u76ee\u7684\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u4ed8\u304d\u3067\u6307\u5b9a\u3057\u3066\u3042\u3052\u308b\u3068OK\u3067\u3059\u3002<\/p>\n<pre>Route::get('route', '<strong>User\\<\/strong>HomeController@route');<\/pre>\n<p>\u3082\u3061\u308d\u3093\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u547c\u3073\u51fa\u3059\u5f62\u3067\u3082\u30d1\u30e9\u30e1\u30fc\u30bf\u3064\u304d\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3084\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3082\u540c\u69d8\u306b\u5229\u7528\u3067\u304d\u307e\u3059\uff01<\/p>\n<p>\u306a\u304a\u3001\u72ec\u81ea\u306e\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u3066\u3001<span style=\"text-decoration: underline;\">\u4f8b\u3048\u3070ID\u3068\u306f\u5225\u306b\u5546\u54c1\u30b3\u30fc\u30c9\u306a\u3069\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u3092\u63a2\u3057\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/span><\/p>\n<p>\u3053\u306e\u5834\u5408\u3001\u307e\u305a\u300c\/app\/Providers\/AppServiceProvider.php\u300d\u306eboot()\u5185\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u72ec\u81ea\u30eb\u30fc\u30eb\u3092\u8ffd\u52a0\u3057\u3066\u3042\u3052\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>\\Route::bind('item_code', function ($value) {<\/strong>\r\n\r\n<strong>    return \\App\\Item::where('product_code', $value)-&gt;first() ?? abort(404);<\/strong>\r\n\r\n<strong>});<\/strong><\/pre>\n<p>\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u00a0<strong>{item_code}\u00a0<\/strong>\u3092\u4f7f\u3063\u3066\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>Route::get('item\/<strong>{item_code}<\/strong>', function(\\App\\Item $item){\r\n\r\n    echo $item-&gt;name;\r\n\r\n});<\/pre>\n<h1>\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u305f\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/h1>\n<p>\u4f8b\u3048\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u7a2e\u985e\u304c\u300c\u7ba1\u7406\u8005\u300d\u3068\u300c\u4f1a\u54e1\u300d\u306e\uff12\u3064\u3060\u3068\u3057\u3066<span style=\"font-size: 1rem;\">\u3001\u305d\u308c\u305e\u308c\u306b\u5c02\u7528\u306eURL\u3092\u4f5c\u308b\u5834\u5408\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/span><\/p>\n<p>\u3053\u306e\u5834\u5408\u304a\u305d\u3089\u304f\u3001<\/p>\n<ul>\n<li>http:\/\/*****.com\/<strong>user\/top<\/strong><\/li>\n<li>http:\/\/*****.com\/<strong>user\/settings<\/strong><\/li>\n<li>http:\/\/*****.com\/<strong>user\/logout<\/strong><\/li>\n<\/ul>\n<p>\u3084\u3001<\/p>\n<ul>\n<li>http:\/\/*****.com\/<strong>admin\/main<\/strong><\/li>\n<li>http:\/\/*****.com\/<strong>admin\/user\/create<\/strong><\/li>\n<li>http:\/\/*****.com\/<strong>admin\/settings<\/strong><\/li>\n<\/ul>\n<p>\u306a\u3069\u306eURL\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u304f\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u3001\u3072\u3068\u3064\u3072\u3068\u3064<\/p>\n<pre>Route::get('user\/top', function(){});\r\nRoute::get('user\/settings', function(){});\r\nRoute::get('user\/logout', function(){});<\/pre>\n<p>\u3068\u66f8\u3044\u3066\u3082\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u3067\u304d\u308c\u3070\u540c\u3058\u76ee\u7684\u306e\u30da\u30fc\u30b8\u306f\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u304a\u304d\u305f\u3044\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u6d3b\u8e8d\u3059\u308b\u306e\u304c<strong>group()<\/strong>\u3067\u3059\u3002<br \/>\n\u30b0\u30eb\u30fc\u30d7\u5316\u306e\u7a2e\u985e\u306f<\/p>\n<ul>\n<li><strong>middleware\u3000\u30fb\u30fb\u30fb\u3000\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3067\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u9069\u7528\u3059\u308b<\/strong><\/li>\n<li><strong>namespace\u3000\u30fb\u30fb\u30fb\u3000\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u3067\u30b0\u30eb\u30fc\u30d7\u5316<\/strong><\/li>\n<li><strong>domain\u3000\u30fb\u30fb\u30fb\u3000\u30b5\u30d6\u30c9\u30e1\u30a4\u30f3\u3092\u30b0\u30eb\u30fc\u30d7\u5316<\/strong><\/li>\n<li><strong>prefix\u3000\u30fb\u30fb\u30fb\u3000URL\u304c\u59cb\u307e\u308b\u6587\u5b57\u5217\u3067\u30b0\u30eb\u30fc\u30d7\u5316<\/strong><\/li>\n<li><strong>name\u3000\u30fb\u30fb\u30fb\u3000\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u540d\u3067\u30b0\u30eb\u30fc\u30d7\u5316<\/strong><\/li>\n<\/ul>\n<p>\u306e\uff15\u3064\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>middleware<\/h2>\n<pre>Route::<strong>middleware('auth')-&gt;group(function(){<\/strong>\r\n\r\n    Route::get('user\/top', 'HomeController@route');\r\n\r\n<strong>});<\/strong><\/pre>\n<p>\u4e2d\u306b\u8a18\u8ff0\u3055\u308c\u305f\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3092\u9069\u7528\u3059\u308b\u66f8\u304d\u65b9\u3067\u3059\u3002\u3053\u306e\u5834\u5408\u306e\u300cauth\u300d\u306f\u3001\u300c\/app\/Http\/Kernel.php\u300d\u5185\u3067\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<h2>namespace<\/h2>\n<pre>Route::<strong>namespace('User')-&gt;group(function(){<\/strong>\r\n\r\n    Route::get('user\/top', '<strong>HomeController@index<\/strong>');\r\n\r\n<strong>});<\/strong><\/pre>\n<p>\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u306b\u300c<strong>User<\/strong>\u300d\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u3092\u6301\u3063\u305f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u304c\u547c\u3073\u51fa\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers\\User;<\/strong><\/pre>\n<p>\u3064\u307e\u308a\u3001\u5148\u307b\u3069\u306e\u4f8b\u3060\u3068\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u300c<strong>HomeController@index<\/strong>\u300d\u3068\u6307\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u5b9f\u969b\u306b\u306f\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u3067\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u300c<strong>User\\HomeController@index<\/strong>\u300d\u304c\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>domain<\/h2>\n<p>\u30b5\u30d6\u30c9\u30e1\u30a4\u30f3\u3067\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>Route::<strong>domain('{account}.laravel.test')-&gt;group(function(){<\/strong>\r\n\r\n    Route::get('user\/top', function(<strong>$account<\/strong>){\r\n\r\n        echo $account;\r\n\r\n    });\r\n\r\n<strong>});<\/strong><\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u300chttp:\/\/laravel.test\/user\/top\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3082\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u304c\u3001\u4f8b\u3048\u3070\u300chttp:\/\/<strong>www.<\/strong>laravel.test\/user\/top\u300d\u3068\u30b5\u30d6\u30c9\u30e1\u30a4\u30f3\u4ed8\u304d\u306a\u3089\u3046\u307e\u304f\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001<strong>$account<\/strong>\u306b\u306f\u300cwww\u300d\u306a\u3069\u306e\u8a72\u5f53\u3059\u308b\u30b5\u30d6\u30c9\u30e1\u30a4\u30f3\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3053\u308c\u3089\u3092\u4f7f\u3063\u3066\u5206\u5c90\u3092\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<h2>prefix<\/h2>\n<p>\u500b\u4eba\u7684\u306b\u3088\u304f\u4f7f\u3046\u306e\u304cprefix\u6a5f\u80fd\u3067\u3059\u3002<br \/>\n\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u6570\u304c\u5897\u3048\u3066\u304f\u308b\u3068\u5c11\u3057\u3067\u3082\u8a18\u8ff0\u30b3\u30fc\u30c9\u3092\u5c11\u306a\u304f\u3057\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u306e\u3067\u3001\u91cd\u5b9d\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u66f8\u304d\u65b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Route::<strong>prefix('user')-&gt;group(function(){<\/strong>\r\n\r\n    Route::get('top', 'HomeController@route');\r\n    Route::get('settings', function(){});\r\n    Route::get('logout', function(){});\r\n\r\n<strong>});<\/strong><\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u6709\u52b9\u306b\u306a\u308bURL\u306f<\/p>\n<ul>\n<li>http:\/\/*****.com\/<strong>user<\/strong>\/top<\/li>\n<li>http:\/\/*****.com\/<strong>user<\/strong>\/settings<\/li>\n<li>http:\/\/*****.com\/<strong>user<\/strong>\/logout<\/li>\n<\/ul>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002\u3064\u307e\u308a\u3001URL\u306e\u6700\u521d\u306e\u6587\u5b57\u5217\u3092\u4e00\u62ec\u3067\u6307\u5b9a\u3067\u304d\u308b\u308f\u3051\u3067\u3059\u306d\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u3001<\/p>\n<pre>Route::<strong>prefix('user\/xxx')<\/strong>-&gt;group(function(){\r\n    \r\n    \/\/\r\n    \r\n});<\/pre>\n<p>\u3068\u3044\u3046\u98a8\u306b\u591a\u968e\u5c64\u3067\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>name<\/h2>\n<p>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u540d\u524d\u3092\u4e00\u62ec\u3067\u6307\u5b9a\u3059\u308b\u66f8\u304d\u65b9\u3067\u3059\u3002<br \/>\n\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u306f<strong>name()<\/strong>\u3067\u7279\u5b9a\u306e\u540d\u524d\u3092\u3064\u3051\u3066\u304a\u304f\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u697d\u306bURL\u3092\u53d6\u5f97\u3067\u304d\u308b\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>echo route('user.top');  \/\/ URL\u304c\u53d6\u5f97\u3067\u304d\u308b<\/strong><\/pre>\n<p>\u3082\u3057\u3001\u3053\u306e\u5834\u5408\u8a18\u8ff0\u3059\u3079\u304d\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Route::<strong>name('user.')-&gt;group(function(){<\/strong>\r\n\r\n    Route::get('user\/top', function(){\r\n\r\n        echo 'OK\u3067\u3059\uff01';\r\n\r\n    })-&gt;<strong>name('top');<\/strong>\r\n\r\n<strong>});<\/strong><\/pre>\n<p>\u3064\u307e\u308a\u3001prefix()\u306a\u3069\u3068\u540c\u69d8\u306b\u300c<strong>user.<\/strong>\u300d\u3092\u4e00\u62ec\u3067\u6307\u5b9a\u3057\u3066\u304a\u3044\u3066\u3001\u4e2d\u8eab\u306f\u300ctop\u300d\u3060\u3051\u3092\u540d\u524d\u4ed8\u3051\u3059\u308b\u3068\u3044\u3046\u66f8\u304d\u65b9\u3067\u3059\u306d\u3002\u305f\u304f\u3055\u3093\u306e\u540d\u524d\u4ed8\u3051\u3092\u3059\u308b\u5834\u5408\u306b\u306f\u6709\u52b9\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>\u8907\u6570\u306e\u30b0\u30eb\u30fc\u30d7\u5316\u3092\u4e00\u62ec\u3067\u3084\u308a\u305f\u3044<\/h2>\n<p>\u8907\u6570\u306e\u30b0\u30eb\u30fc\u30d7\u5316\u3092\u6307\u5b9a\u3057\u305f\u3044\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u300c<strong>-&gt;<\/strong>\u300d\u30a2\u30ed\u30fc\u3067\u7e4b\u3052\u3070\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre>Route::<strong>prefix('user')-&gt;middleware('auth')<\/strong>-&gt;group(function(){\r\n\r\n    \/\/\r\n\r\n});<\/pre>\n<p>\u3082\u3057\u304f\u306f\u3001Laravel5.6\u306e\u516c\u5f0f\u30da\u30fc\u30b8\u306b\u306f\u66f8\u304b\u308c\u3066\u307e\u305b\u3093\u304c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bgroup()\u5185\u306b\u914d\u5217\u3067\u6307\u5b9a\u3057\u3066\u3084\u308b\u3053\u3068\u3067\u8907\u6570\u30bf\u30a4\u30d7\u306e\u30b0\u30eb\u30fc\u30d7\u5316\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>Route::group(<strong>['prefix' =&gt; 'user', 'middleware' =&gt; 'auth']<\/strong>, function(){\r\n\r\n    \/\/ \r\n\r\n});<\/pre>\n<h1>RESTful\u306a\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/h1>\n<p>RESTful\u5316\u3057\u305f\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u7c21\u5358\u306b\u5b9f\u73fe\u3057\u305f\u3044\u5834\u5408\u306f<strong>resource()<\/strong>\u3092\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u3068\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u6307\u5b9a\u3059\u308b\u3060\u3051\u3067\u3001\u6b21\u306eURL\u304c\u6709\u52b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>Route::resource('users', 'UserController');<\/strong><\/pre>\n<ul>\n<li>(GET) http:\/\/*****.com\/users\u3000\u30fb\u30fb\u30fb\u3000\u4e00\u89a7\u8868\u793a\u3002index()<\/li>\n<li>(GET) http:\/\/*****.com\/users\/create\u3000\u30fb\u30fb\u30fb\u3000\u8ffd\u52a0\u30da\u30fc\u30b8\u3002create()<\/li>\n<li>(POST)\u00a0http:\/\/*****.com\/users\u3000\u30fb\u30fb\u30fb\u3000\u8ffd\u52a0\u3002store()<\/li>\n<li>(GET)\u00a0http:\/\/*****.com\/users\/1\u3000\u30fb\u30fb\u30fb\u3000\u8a72\u5f53\u30c7\u30fc\u30bf\u8868\u793a\u3002show()<\/li>\n<li>(GET)\u00a0http:\/\/*****.com\/users\/1\/edit\u3000\u30fb\u30fb\u30fb\u3000\u66f4\u65b0\u30da\u30fc\u30b8\u3002edit()<\/li>\n<li>(PUT)\u00a0http:\/\/*****.com\/users\/1\u3000\u30fb\u30fb\u30fb\u3000\u66f4\u65b0\u3002update()<\/li>\n<li>(DELETE)\u00a0http:\/\/*****.com\/users\/1\u3000\u30fb\u30fb\u30fb\u3000\u524a\u9664\u3002destroy()<\/li>\n<\/ul>\n<p>\u3082\u3057\u3001\u7279\u5b9a\u306e\u30da\u30fc\u30b8\u3060\u3051\u6709\u52b9\u306b\u3057\u305f\u3044\u5834\u5408\u306fonly()\u3001\u7279\u5b9a\u306e\u30da\u30fc\u30b8\u3092\u9664\u5916\u3057\u305f\u3044\u5834\u5408\u306fexcept()\u3092\u4f7f\u3063\u3066\u6307\u5b9a\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>Route::resource('user', 'UserController')-&gt;<strong>only([<\/strong>\r\n<strong>    'index', 'show' \/\/ \u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u6709\u52b9<\/strong>\r\n<strong>])<\/strong>;<\/pre>\n<pre>Route::resource('user', 'UserController')-&gt;<strong>except([<\/strong>\r\n<strong>    'store', 'update' \/\/ \u3053\u306e\u30e1\u30bd\u30c3\u30c9\u4ee5\u5916\u304c\u6709\u52b9<\/strong>\r\n<strong>])<\/strong>;<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001RESTful\u7528\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bartisan\u30b3\u30de\u30f3\u30c9\u306b\u300c<strong>&#8211;resouce<\/strong>\u300d\u3092\u3064\u3051\u308c\u3070\u4e00\u6c17\u306bindex()\u4ee5\u4e0b\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u66f8\u304b\u308c\u305f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u81ea\u52d5\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>php artisan make:controller ItemController <strong>--resource<\/strong><\/pre>\n<h1>ID\u4ee5\u5916\u3067\u30e2\u30c7\u30eb\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3059\u308b<\/h1>\n<p><a href=\"https:\/\/blog.capilano-fw.com\/?p=6020#custom_pk\">Laravel 7.x\u306e\u65b0\u30eb\u30fc\u30c8\u6a5f\u80fd &gt; ID\u4ee5\u5916\u3067\u30e2\u30c7\u30eb\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u65b9\u6cd5<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 7.x \u4ee5\u964d<\/em><\/p>\n<h1>\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u3092\u8003\u616e\u3057\u305f\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0<\/h1>\n<p><a href=\"https:\/\/blog.capilano-fw.com\/?p=6020#route_combination\">Laravel 7.x\u306e\u65b0\u30eb\u30fc\u30c8\u6a5f\u80fd &gt;\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u3092\u8003\u616e\u3057\u305f\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 7.x \u4ee5\u964d<\/em><\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u4eca\u56de\u306fLaravel\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u3064\u3044\u3066\u306e\u5b9f\u4f8b\u3092\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u5e38\u306b\u65b0\u3057\u3044\u66f8\u304d\u65b9\u304c\u8ffd\u52a0\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u3082\u3057\u77e5\u3089\u306a\u3044\u65b9\u6cd5\u3092\u767a\u898b\u3057\u3066\u3082\u3089\u3048\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\u3002<\/p>\n<p>\u305c\u3072\u4f5c\u696d\u306e\u52b9\u7387\u5316\u3092\u9032\u3081\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-418 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/35.png\" alt=\"\" width=\"370\" height=\"240\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/35.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/35-300x195.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u4eca\u3082\u9032\u5316\u3092\u7d9a\u3051\u308bLaravel\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u5c11\u3057\u8996\u70b9\u3092\u5909\u3048\u3066\u76f4\u63a5\u76ee\u306b\u898b\u3048\u308b\u90e8\u5206\u3067\u306f\u306a\u304f\u3001\u3088\u308a\u6839\u672c\u7684\u306a\u300c\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\uff08Routing\uff09\u300d\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u3066 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=556\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel\u306eRoute\u3001\u5168\uff18\u30d1\u30bf\u30fc\u30f3\u5b9f\u4f8b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":6204,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[70],"class_list":["post-556","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-70"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/556","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=556"}],"version-history":[{"count":17,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/556\/revisions"}],"predecessor-version":[{"id":6213,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/556\/revisions\/6213"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/6204"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}