{"id":1568,"date":"2026-05-18T18:54:15","date_gmt":"2026-05-18T09:54:15","guid":{"rendered":"https:\/\/blog.nexive.tech\/?p=1568"},"modified":"2026-05-18T19:25:05","modified_gmt":"2026-05-18T10:25:05","slug":"laravel-controller-roles","status":"publish","type":"post","link":"https:\/\/blog.nexive.tech\/?p=1568","title":{"rendered":"\u3010\u521d\u5fc3\u8005\u5411\u3051\u3011Laravel\u3067Controller\u3092\u4f5c\u308b\u524d\u306b\u77e5\u308a\u305f\u3044\u5f79\u5272\u5206\u62c5"},"content":{"rendered":"\n<p>Laravel\u3092\u5b66\u3073\u59cb\u3081\u308b\u3068\u3001\u65e9\u3044\u6bb5\u968e\u3067Controller\u304c\u51fa\u3066\u304d\u307e\u3059\u3002<code>php artisan make:controller<\/code> \u3067\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308c\u308b\u3053\u3068\u306f\u5206\u304b\u3063\u3066\u3082\u3001\u305d\u3053\u306b\u4f55\u3092\u66f8\u3051\u3070\u3088\u3044\u306e\u304b\u3067\u624b\u304c\u6b62\u307e\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>Route\u306b\u3082\u51e6\u7406\u3092\u66f8\u3051\u308b\u3002Controller\u306b\u3082\u66f8\u3051\u308b\u3002Model\u3082\u3042\u308b\u3002View\u3082\u3042\u308b\u3002\u3055\u3089\u306bRequest\u3068\u3044\u3046\u8a00\u8449\u3082\u51fa\u3066\u304f\u308b\u3002\u521d\u5fc3\u8005\u304c\u8ff7\u3046\u306e\u306f\u81ea\u7136\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001Laravel\u3067Controller\u3092\u4f5c\u308b\u524d\u306b\u77e5\u3063\u3066\u304a\u304d\u305f\u3044\u5f79\u5272\u5206\u62c5\u3092\u6574\u7406\u3057\u307e\u3059\u3002\u96e3\u3057\u3044\u8a2d\u8a08\u8ad6\u3067\u306f\u306a\u304f\u3001Route\u3001Controller\u3001Model\u3001View\u3001Request\u3092\u3069\u3046\u5206\u3051\u3066\u8003\u3048\u308b\u3068\u7406\u89e3\u3057\u3084\u3059\u3044\u304b\u3092\u3001\u77ed\u3044\u30b3\u30fc\u30c9\u4f8b\u3067\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Controller\u3067\u8ff7\u3046\u306e\u306f\u3001\u4f55\u3067\u3082\u66f8\u3051\u3066\u3057\u307e\u3046\u304b\u3089<\/h2>\n\n\n\n<p>Laravel\u3067\u306f\u3001\u7c21\u5358\u306a\u51e6\u7406\u306a\u3089 <code>routes\/web.php<\/code> \u306b\u76f4\u63a5\u66f8\u304f\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u5b66\u7fd2\u306e\u6700\u521d\u306f\u3001\u305d\u308c\u3067\u52d5\u304d\u3092\u78ba\u8a8d\u3059\u308b\u65b9\u304c\u5206\u304b\u308a\u3084\u3059\u3044\u5834\u9762\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305f\u3060\u3001\u753b\u9762\u304c\u5897\u3048\u305f\u308a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u5024\u3092\u53d6\u3063\u305f\u308a\u3001\u30d5\u30a9\u30fc\u30e0\u9001\u4fe1\u3092\u53d7\u3051\u305f\u308a\u3059\u308b\u3068\u3001Route\u306e\u4e2d\u3060\u3051\u3067\u51e6\u7406\u3059\u308b\u306e\u306f\u82e6\u3057\u304f\u306a\u308a\u307e\u3059\u3002\u305d\u3053\u3067Controller\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u3053\u3067\u3064\u307e\u305a\u304d\u3084\u3059\u3044\u306e\u306f\u3001Controller\u306b\u3082\u3044\u308d\u3044\u308d\u66f8\u3051\u3066\u3057\u307e\u3046\u3053\u3068\u3067\u3059\u3002\u30c7\u30fc\u30bf\u53d6\u5f97\u3001\u6761\u4ef6\u5206\u5c90\u3001\u8868\u793a\u7528\u30c7\u30fc\u30bf\u306e\u6574\u5f62\u3001\u4fdd\u5b58\u51e6\u7406\u3001\u30a8\u30e9\u30fc\u51e6\u7406\u3002\u5168\u90e8\u66f8\u3053\u3046\u3068\u601d\u3048\u3070\u66f8\u3051\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3057\u304b\u3057\u3001\u5168\u90e8\u3092Controller\u306b\u96c6\u3081\u308b\u3068\u3001\u3059\u3050\u306b\u8aad\u307f\u306b\u304f\u304f\u306a\u308a\u307e\u3059\u3002\u6700\u521d\u306f\u7d30\u304b\u3044\u8a2d\u8a08\u30d1\u30bf\u30fc\u30f3\u3092\u899a\u3048\u308b\u3088\u308a\u3001\u6b21\u306e\u3088\u3046\u306b\u3056\u3063\u304f\u308a\u5206\u3051\u308b\u3060\u3051\u3067\u5341\u5206\u3067\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Route\u306f\u5165\u53e3<\/li>\n\n\n\n<li>Controller\u306f\u51e6\u7406\u306e\u6d41\u308c\u3092\u7d44\u307f\u7acb\u3066\u308b\u5834\u6240<\/li>\n\n\n\n<li>Model\u306f\u30c7\u30fc\u30bf\u3092\u6271\u3046\u5834\u6240<\/li>\n\n\n\n<li>View\u306f\u8868\u793a\u3059\u308b\u5834\u6240<\/li>\n\n\n\n<li>Request\u306f\u5165\u529b\u3092\u53d7\u3051\u53d6\u308b\u5165\u53e3<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u306e\u5206\u3051\u65b9\u304c\u898b\u3048\u3066\u304f\u308b\u3068\u3001Controller\u306b\u4f55\u3092\u66f8\u304f\u304b\u3082\u6c7a\u3081\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Controller\u306e\u5f79\u5272\u306f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u3066\u6b21\u3078\u6e21\u3059\u3053\u3068<\/h2>\n\n\n\n<p>Controller\u306f\u3001Route\u304b\u3089\u547c\u3070\u308c\u3066\u3001\u5fc5\u8981\u306a\u51e6\u7406\u3092\u7d44\u307f\u7acb\u3066\u3001\u6700\u5f8c\u306b\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059\u5834\u6240\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u305f\u3068\u3048\u3070\u6295\u7a3f\u4e00\u89a7\u30da\u30fc\u30b8\u306a\u3089\u3001Controller\u306f\u300c\u6295\u7a3f\u4e00\u89a7\u3092\u8868\u793a\u3057\u305f\u3044\u300d\u3068\u3044\u3046\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u53d6\u308a\u307e\u3059\u3002\u305d\u3057\u3066Model\u304b\u3089\u6295\u7a3f\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3001View\u3078\u6e21\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u3068\u304dController\u304c\u62c5\u5f53\u3059\u308b\u306e\u306f\u3001\u5168\u4f53\u306e\u6d41\u308c\u3067\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u3069\u306e\u5165\u529b\u3092\u53d7\u3051\u53d6\u308b\u304b<\/li>\n\n\n\n<li>\u3069\u306eModel\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u308b\u304b<\/li>\n\n\n\n<li>\u3069\u306eView\u3078\u6e21\u3059\u304b<\/li>\n\n\n\n<li>\u6700\u5f8c\u306b\u4f55\u3092\u8fd4\u3059\u304b<\/li>\n<\/ul>\n\n\n\n<p><strong>Controller\u306f\u3001\u30a2\u30d7\u30ea\u306e\u51e6\u7406\u3092\u5168\u90e8\u62b1\u3048\u8fbc\u3080\u5834\u6240\u3067\u306f\u306a\u304f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u304b\u3089\u30ec\u30b9\u30dd\u30f3\u30b9\u307e\u3067\u3092\u3064\u306a\u3050\u5834\u6240\u3067\u3059\u3002<\/strong><\/p>\n\n\n\n<p>\u521d\u5fc3\u8005\u306e\u3046\u3061\u306f\u3001Controller\u3092\u300c\u4ea4\u901a\u6574\u7406\u5f79\u300d\u3068\u8003\u3048\u308b\u3068\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3002Route\u304b\u3089\u6765\u305f\u3082\u306e\u3092\u53d7\u3051\u53d6\u308a\u3001\u5fc5\u8981\u306a\u76f8\u624b\u306b\u6e21\u3057\u3001View\u3084\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3068\u3057\u3066\u8fd4\u3059\u3002\u307e\u305a\u306f\u3053\u306e\u611f\u899a\u3067\u5341\u5206\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Route\u3001Model\u3001View\u3001Request\u3068\u306e\u9055\u3044\u3092\u5206\u3051\u3066\u8003\u3048\u308b<\/h2>\n\n\n\n<p>Controller\u306e\u5f79\u5272\u3092\u7406\u89e3\u3059\u308b\u306b\u306f\u3001\u5468\u308a\u306e\u30d5\u30a1\u30a4\u30eb\u3068\u306e\u9055\u3044\u3092\u898b\u308b\u306e\u304c\u65e9\u3044\u3067\u3059\u3002Laravel\u3067\u306f\u3001\u305d\u308c\u305e\u308c\u304c\u5b8c\u5168\u306b\u72ec\u7acb\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u3088\u308a\u3001\u5f79\u5272\u3092\u5206\u62c5\u3057\u306a\u304c\u3089\u4e00\u3064\u306e\u51e6\u7406\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Route\u306f\u300c\u3069\u306eURL\u3067\u4f55\u3092\u547c\u3076\u304b\u300d\u3092\u6c7a\u3081\u308b<\/h3>\n\n\n\n<p>Route\u306f\u3001URL\u3068\u51e6\u7406\u306e\u5bfe\u5fdc\u3092\u6c7a\u3081\u308b\u5165\u53e3\u3067\u3059\u3002\u305f\u3068\u3048\u3070 <code>\/posts<\/code> \u306b\u30a2\u30af\u30bb\u30b9\u3055\u308c\u305f\u3089 <code>PostController<\/code> \u306e <code>index<\/code> \u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3076\u3001\u3068\u3044\u3046\u5bfe\u5fdc\u3092\u66f8\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#2e3440\"><span style=\"background:#c8d0e0;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#2e3440\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>use App\\Http\\Controllers\\PostController;\nuse Illuminate\\Support\\Facades\\Route;\n\nRoute::get('\/posts', &#91;PostController::class, 'index'&#93;);<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">use<\/span><span style=\"color: #D8DEE9FF\"> App<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Http<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Controllers<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #8FBCBB\">PostController<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">use<\/span><span style=\"color: #D8DEE9FF\"> Illuminate<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Support<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Facades<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #8FBCBB\">Route<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #8FBCBB\">Route<\/span><span style=\"color: #81A1C1\">::<\/span><span style=\"color: #88C0D0\">get<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">\/posts<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #8FBCBB\">PostController<\/span><span style=\"color: #81A1C1\">::class<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">index<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">&#93;)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u3053\u3067\u5927\u4e8b\u306a\u306e\u306f\u3001Route\u306b\u51e6\u7406\u3092\u9577\u304f\u66f8\u304d\u3059\u304e\u306a\u3044\u3053\u3068\u3067\u3059\u3002Route\u306f\u300c\u3069\u306eURL\u3067\u4f55\u3092\u547c\u3076\u304b\u300d\u3092\u8aad\u3080\u5834\u6240\u3068\u3057\u3066\u4f7f\u3046\u3068\u3001\u3042\u3068\u304b\u3089\u898b\u8fd4\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Model\u306f\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u3084\u4fdd\u5b58\u3092\u62c5\u5f53\u3059\u308b<\/h3>\n\n\n\n<p>Model\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c6\u30fc\u30d6\u30eb\u3068\u8fd1\u3044\u5834\u6240\u306b\u3044\u308b\u3082\u306e\u3067\u3059\u3002Laravel\u3067\u306fEloquent Model\u3092\u4f7f\u3063\u3066\u3001\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u3084\u4fdd\u5b58\u3092\u6271\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6295\u7a3f\u4e00\u89a7\u306a\u3089\u3001Controller\u304c\u76f4\u63a5SQL\u3092\u66f8\u304f\u306e\u3067\u306f\u306a\u304f\u3001<code>Post<\/code> Model\u3092\u4f7f\u3063\u3066\u6295\u7a3f\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#2e3440\"><span style=\"background:#c8d0e0;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#2e3440\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>$posts = Post::latest()->get();<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">$<\/span><span style=\"color: #D8DEE9\">posts<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">Post<\/span><span style=\"color: #81A1C1\">::<\/span><span style=\"color: #88C0D0\">latest<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #81A1C1\">-&gt;<\/span><span style=\"color: #88C0D0\">get<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #81A1C1\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e1\u884c\u3060\u3051\u898b\u308b\u3068Controller\u306b\u66f8\u3044\u3066\u3082\u3088\u3055\u305d\u3046\u3067\u3059\u304c\u3001\u30c7\u30fc\u30bf\u306b\u95a2\u3059\u308b\u7d30\u304b\u3044\u6761\u4ef6\u304c\u5897\u3048\u3066\u304d\u305f\u3089\u3001Model\u5074\u3078\u5bc4\u305b\u308b\u3053\u3068\u3082\u8003\u3048\u307e\u3059\u3002\u6700\u521d\u304b\u3089\u96e3\u3057\u304f\u5206\u3051\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u305f\u3060\u3001\u30c7\u30fc\u30bf\u306e\u8a71\u306fModel\u306b\u8fd1\u3044\u3001\u3068\u899a\u3048\u3066\u304a\u304f\u3068\u6574\u7406\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">View\u306f\u8868\u793a\u3092\u62c5\u5f53\u3057\u3001Controller\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d7\u3051\u53d6\u308b<\/h3>\n\n\n\n<p>View\u306f\u753b\u9762\u3092\u8868\u793a\u3059\u308b\u5834\u6240\u3067\u3059\u3002Laravel\u3067\u306f\u591a\u304f\u306e\u5834\u5408\u3001Blade\u30d5\u30a1\u30a4\u30eb\u3092 <code>resources\/views<\/code> \u914d\u4e0b\u306b\u7f6e\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>Controller\u306f\u3001\u5fc5\u8981\u306a\u30c7\u30fc\u30bf\u3092View\u3078\u6e21\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#2e3440\"><span style=\"background:#c8d0e0;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#2e3440\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>return view('posts.index', &#91;'posts' => $posts&#93;);<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">view<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">posts.index<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #88C0D0\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">posts<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #88C0D0\"> <\/span><span style=\"color: #81A1C1\">=&gt;<\/span><span style=\"color: #88C0D0\"> <\/span><span style=\"color: #81A1C1\">$<\/span><span style=\"color: #D8DEE9\">posts<\/span><span style=\"color: #ECEFF4\">&#93;)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>View\u5074\u3067\u306f\u3001\u53d7\u3051\u53d6\u3063\u305f <code>$posts<\/code> \u3092\u4f7f\u3063\u3066HTML\u3092\u7d44\u307f\u7acb\u3066\u307e\u3059\u3002\u3053\u3053\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u6295\u7a3f\u3092\u53d6\u5f97\u3059\u308b\u51e6\u7406\u307e\u3067\u66f8\u304d\u59cb\u3081\u308b\u3068\u3001\u8868\u793a\u3068\u30c7\u30fc\u30bf\u53d6\u5f97\u304c\u6df7\u3056\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>View\u306f\u898b\u305f\u76ee\u3092\u4f5c\u308b\u5834\u6240\u3001Controller\u306fView\u306b\u6e21\u3059\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3059\u308b\u5834\u6240<\/strong>\u3068\u8003\u3048\u308b\u3068\u3001\u6700\u521d\u306f\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Request\u306f\u5165\u529b\u5024\u3092\u53d7\u3051\u53d6\u308b\u5165\u53e3\u306b\u306a\u308b<\/h3>\n\n\n\n<p>\u30d5\u30a9\u30fc\u30e0\u9001\u4fe1\u3084\u691c\u7d22\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u6271\u3046\u3068\u304d\u306f\u3001Request\u304c\u51fa\u3066\u304d\u307e\u3059\u3002Request\u306f\u3001\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u5c4a\u3044\u305f\u5165\u529b\u3084\u30ea\u30af\u30a8\u30b9\u30c8\u60c5\u5831\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305f\u3068\u3048\u3070\u691c\u7d22\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u53d7\u3051\u53d6\u308b\u306a\u3089\u3001Controller\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u6b21\u306e\u3088\u3046\u306b\u6271\u3048\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#2e3440\"><span style=\"background:#c8d0e0;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#2e3440\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>public function index(Request $request)\n{\n    $keyword = $request->input('keyword');\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">public<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">function<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">index<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #8FBCBB\">Request<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">$<\/span><span style=\"color: #D8DEE9\">request<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">$<\/span><span style=\"color: #D8DEE9\">keyword<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">$<\/span><span style=\"color: #D8DEE9\">request<\/span><span style=\"color: #81A1C1\">-&gt;<\/span><span style=\"color: #88C0D0\">input<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">keyword<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u7d30\u304b\u3044\u8a71\u306f\u5225\u3067\u5b66\u3079\u3070\u5927\u4e08\u592b\u3067\u3059\u3002\u307e\u305a\u306f\u3001\u5165\u529b\u5024\u306fRequest\u304b\u3089\u6765\u308b\u3001\u3068\u62bc\u3055\u3048\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c0f\u3055\u306a\u4e00\u89a7\u8868\u793a\u3067\u5f79\u5272\u5206\u62c5\u3092\u898b\u308b<\/h2>\n\n\n\n<p>\u3053\u3053\u307e\u3067\u306e\u5f79\u5272\u3092\u3001\u6295\u7a3f\u4e00\u89a7\u306e\u4f8b\u3067\u3064\u306a\u3052\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305aRoute\u3067\u3001URL\u3068Controller\u3092\u3064\u306a\u304e\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#2e3440\"><span style=\"background:#c8d0e0;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#2e3440\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>use App\\Http\\Controllers\\PostController;\nuse Illuminate\\Support\\Facades\\Route;\n\nRoute::get('\/posts', &#91;PostController::class, 'index'&#93;);<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">use<\/span><span style=\"color: #D8DEE9FF\"> App<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Http<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Controllers<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #8FBCBB\">PostController<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">use<\/span><span style=\"color: #D8DEE9FF\"> Illuminate<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Support<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Facades<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #8FBCBB\">Route<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #8FBCBB\">Route<\/span><span style=\"color: #81A1C1\">::<\/span><span style=\"color: #88C0D0\">get<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">\/posts<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #8FBCBB\">PostController<\/span><span style=\"color: #81A1C1\">::class<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">index<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">&#93;)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u6b21\u306bController\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#2e3440\"><span style=\"background:#c8d0e0;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#2e3440\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>namespace App\\Http\\Controllers;\n\nuse App\\Models\\Post;\nuse Illuminate\\View\\View;\n\nclass PostController extends Controller\n{\n    public function index(): View\n    {\n        $posts = Post::latest()->get();\n\n        return view('posts.index', &#91;\n            'posts' => $posts,\n        &#93;);\n    }\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">namespace<\/span><span style=\"color: #D8DEE9FF\"> App<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Http<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Controllers<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">use<\/span><span style=\"color: #D8DEE9FF\"> App<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">Models<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #8FBCBB\">Post<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">use<\/span><span style=\"color: #D8DEE9FF\"> Illuminate<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #D8DEE9FF\">View<\/span><span style=\"color: #ECEFF4\">\\<\/span><span style=\"color: #8FBCBB\">View<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">PostController<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">extends<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB; font-weight: bold\">Controller<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">public<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">function<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">index<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #81A1C1\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">View<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">$<\/span><span style=\"color: #D8DEE9\">posts<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">Post<\/span><span style=\"color: #81A1C1\">::<\/span><span style=\"color: #88C0D0\">latest<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #81A1C1\">-&gt;<\/span><span style=\"color: #88C0D0\">get<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">view<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">posts.index<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #88C0D0\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">            <\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">posts<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #88C0D0\"> <\/span><span style=\"color: #81A1C1\">=&gt;<\/span><span style=\"color: #88C0D0\"> <\/span><span style=\"color: #81A1C1\">$<\/span><span style=\"color: #D8DEE9\">posts<\/span><span style=\"color: #ECEFF4\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">        <\/span><span style=\"color: #ECEFF4\">&#93;)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001Controller\u304c\u3084\u3063\u3066\u3044\u308b\u3053\u3068\u306f\u591a\u304f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>1. <code>Post<\/code> Model\u304b\u3089\u6295\u7a3f\u3092\u53d6\u5f97\u3059\u308b 2. <code>posts.index<\/code> \u3068\u3044\u3046View\u3092\u9078\u3076 3. View\u3078 <code>$posts<\/code> \u3092\u6e21\u3059<\/p>\n\n\n\n<p>\u305d\u3057\u3066View\u3067\u306f\u3001\u53d7\u3051\u53d6\u3063\u305f\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#2e3440\"><span style=\"background:#c8d0e0;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#2e3440\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>@foreach ($posts as $post)\n    &lt;h2>{{ $post->title }}&lt;\/h2>\n@endforeach<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">@foreach<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">$<\/span><span style=\"color: #D8DEE9\">posts<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">as<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">$<\/span><span style=\"color: #D8DEE9\">post<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">&lt;<\/span><span style=\"color: #D8DEE9FF\">h2<\/span><span style=\"color: #81A1C1\">&gt;<\/span><span style=\"color: #ECEFF4\">{{<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">$<\/span><span style=\"color: #D8DEE9\">post<\/span><span style=\"color: #81A1C1\">-&gt;<\/span><span style=\"color: #D8DEE9\">title<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">}}<\/span><span style=\"color: #81A1C1\">&lt;\/<\/span><span style=\"color: #D8DEE9FF\">h2<\/span><span style=\"color: #81A1C1\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">@endforeach<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u308c\u3060\u3051\u3067\u3082\u3001Route\u3001Controller\u3001Model\u3001View\u306e\u6d41\u308c\u304c\u898b\u3048\u307e\u3059\u3002Route\u304c\u5165\u53e3\u3092\u6c7a\u3081\u3001Controller\u304c\u6d41\u308c\u3092\u4f5c\u308a\u3001Model\u304c\u30c7\u30fc\u30bf\u3092\u6271\u3044\u3001View\u304c\u8868\u793a\u3059\u308b\u3002\u521d\u5fc3\u8005\u306e\u3046\u3061\u306f\u3001\u3053\u306e\u6d41\u308c\u3092\u4f55\u5ea6\u304b\u5c0f\u3055\u304f\u4f5c\u308b\u306e\u304c\u8fd1\u9053\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Controller\u306b\u8a70\u3081\u8fbc\u307f\u3059\u304e\u306a\u3044\u305f\u3081\u306e\u5224\u65ad<\/h2>\n\n\n\n<p>Controller\u306f\u4fbf\u5229\u306a\u306e\u3067\u3001\u6c17\u3065\u304f\u3068\u9577\u304f\u306a\u308a\u307e\u3059\u3002\u6700\u521d\u306e\u3046\u3061\u306f\u3001\u591a\u5c11\u9577\u304f\u306a\u308b\u3053\u3068\u81ea\u4f53\u306f\u73cd\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002\u554f\u984c\u306f\u3001\u4f55\u306e\u51e6\u7406\u304c\u6df7\u3056\u3063\u3066\u3044\u308b\u306e\u304b\u5206\u304b\u3089\u306a\u304f\u306a\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u8ff7\u3063\u305f\u3089\u3001Controller\u306e\u4e2d\u3092\u6b21\u306e\u3088\u3046\u306b\u898b\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>URL\u3084HTTP\u30e1\u30bd\u30c3\u30c9\u306e\u8a71\u3092\u3057\u3066\u3044\u308b\u306a\u3089Route\u5bc4\u308a<\/li>\n\n\n\n<li>\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u3084\u4fdd\u5b58\u306e\u8a71\u3092\u3057\u3066\u3044\u308b\u306a\u3089Model\u5bc4\u308a<\/li>\n\n\n\n<li>HTML\u3084\u898b\u305f\u76ee\u306e\u8a71\u3092\u3057\u3066\u3044\u308b\u306a\u3089View\u5bc4\u308a<\/li>\n\n\n\n<li>\u5165\u529b\u5024\u306e\u53d6\u5f97\u3084\u78ba\u8a8d\u306e\u8a71\u3092\u3057\u3066\u3044\u308b\u306a\u3089Request\u5bc4\u308a<\/li>\n\n\n\n<li>\u305d\u308c\u3089\u3092\u3064\u306a\u3050\u6d41\u308c\u306a\u3089Controller\u306e\u5f79\u5272<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u3053\u3067\u5927\u4e8b\u306a\u306e\u306f\u3001\u6700\u521d\u304b\u3089\u5b8c\u74a7\u306b\u5206\u3051\u3088\u3046\u3068\u3057\u306a\u3044\u3053\u3068\u3067\u3059\u3002\u521d\u5fc3\u8005\u306e\u6bb5\u968e\u3067Service\u5c64\u3084Repository\u3092\u7121\u7406\u306b\u4f5c\u308b\u3068\u3001\u304b\u3048\u3063\u3066\u5168\u4f53\u50cf\u304c\u898b\u3048\u306b\u304f\u304f\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305a\u306fController\u306b\u66f8\u3044\u305f\u51e6\u7406\u3092\u898b\u3066\u3001\u300c\u3053\u308c\u306f\u672c\u5f53\u306bController\u304c\u6301\u3064\u8a71\u304b\u300d\u3068\u7acb\u3061\u6b62\u307e\u308c\u308b\u3060\u3051\u3067\u5341\u5206\u3067\u3059\u3002\u9577\u304f\u306a\u3063\u305f\u3089\u3001\u8868\u793a\u3001\u5165\u529b\u3001\u30c7\u30fc\u30bf\u53d6\u5f97\u3001\u4fdd\u5b58\u51e6\u7406\u304c\u6df7\u3056\u3063\u3066\u3044\u306a\u3044\u304b\u3092\u898b\u76f4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>Laravel\u3067Controller\u3092\u4f5c\u308b\u524d\u306b\u5927\u4e8b\u306a\u306e\u306f\u3001Controller\u3092\u4f55\u3067\u3082\u66f8\u304f\u5834\u6240\u306b\u3057\u306a\u3044\u3053\u3068\u3067\u3059\u3002Controller\u306fRoute\u304b\u3089\u547c\u3070\u308c\u3001\u5fc5\u8981\u306a\u51e6\u7406\u3092\u3064\u306a\u304e\u3001View\u3084\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059\u5834\u6240\u3068\u3057\u3066\u8003\u3048\u308b\u3068\u6574\u7406\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u62bc\u3055\u3048\u3066\u304a\u304d\u305f\u3044\u5f79\u5272\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Route\u306fURL\u3068Controller\u3092\u3064\u306a\u3050\u5165\u53e3<\/li>\n\n\n\n<li>Controller\u306f\u51e6\u7406\u306e\u6d41\u308c\u3092\u7d44\u307f\u7acb\u3066\u308b\u5834\u6240<\/li>\n\n\n\n<li>Model\u306f\u30c7\u30fc\u30bf\u53d6\u5f97\u3084\u4fdd\u5b58\u3092\u62c5\u5f53\u3059\u308b\u5834\u6240<\/li>\n\n\n\n<li>View\u306f\u8868\u793a\u3092\u62c5\u5f53\u3059\u308b\u5834\u6240<\/li>\n\n\n\n<li>Request\u306f\u5165\u529b\u5024\u3092\u53d7\u3051\u53d6\u308b\u5165\u53e3<\/li>\n<\/ul>\n\n\n\n<p>\u307e\u305a\u306f\u5c0f\u3055\u306a\u4e00\u89a7\u8868\u793a\u3092\u4f5c\u308a\u3001Route\u3001Controller\u3001Model\u3001View\u306e\u6d41\u308c\u3092\u78ba\u8a8d\u3057\u3066\u307f\u308b\u306e\u304c\u3088\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u5f79\u5272\u5206\u62c5\u304c\u898b\u3048\u3066\u304f\u308b\u3068\u3001Controller\u306b\u4f55\u3092\u66f8\u3051\u3070\u3088\u3044\u304b\u3001\u4f55\u3092\u66f8\u304d\u3059\u304e\u306a\u3044\u65b9\u304c\u3088\u3044\u304b\u3082\u5224\u65ad\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel\u3092\u5b66\u3073\u59cb\u3081\u308b\u3068\u3001\u65e9\u3044\u6bb5\u968e\u3067Controller\u304c\u51fa\u3066\u304d\u307e\u3059\u3002 php artisan make:controller \u3067\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308c\u308b\u3053\u3068\u306f\u5206\u304b\u3063\u3066\u3082\u3001\u305d\u3053\u306b\u4f55\u3092\u66f8\u3051\u3070\u3088\u3044\u306e\u304b\u3067\u624b\u304c\u6b62\u307e\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002 Route\u306b\u3082\u51e6\u7406&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1570,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[115],"tags":[133,134,135,136,137],"class_list":["post-1568","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","tag-laravel","tag-controller","tag-php","tag-mvc","tag-137"],"_links":{"self":[{"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/1568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1568"}],"version-history":[{"count":2,"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/1568\/revisions"}],"predecessor-version":[{"id":1577,"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/1568\/revisions\/1577"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=\/wp\/v2\/media\/1570"}],"wp:attachment":[{"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}