{"id":62,"date":"2021-03-19T19:20:11","date_gmt":"2021-03-19T10:20:11","guid":{"rendered":"https:\/\/software.satoshis.jp\/?p=62"},"modified":"2021-05-21T16:09:03","modified_gmt":"2021-05-21T07:09:03","slug":"laravel%e3%81%a7post%e3%81%97%e3%81%a6%e3%82%82controller%e3%81%8c%e5%91%bc%e3%81%b3%e5%87%ba%e3%81%95%e3%82%8c%e3%81%aa%e3%81%84%e3%81%82%e3%82%8b%e3%81%82%e3%82%8b","status":"publish","type":"post","link":"https:\/\/software.satoshis.jp\/?p=62","title":{"rendered":"Laravel\u3067POST\u3057\u3066\u3082Controller\u304c\u547c\u3073\u51fa\u3055\u308c\u306a\u3044\u3042\u308b\u3042\u308b"},"content":{"rendered":"<p>Laravel\u3067POST\u3057\u3066\u3082Controller\u304c\u547c\u3073\u51fa\u3055\u308c\u306a\u304f\u3066\u3001\u3061\u3087\u3063\u3068\u30cf\u30de\u3063\u305f\u8a71\u3002<\/p>\n<p>route\/web.php\u306b\u306f\u3001\u304d\u3061\u3093\u3068\u66f8\u3044\u3066\u3042\u308b\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nRoute::post('\/hoge', 'IndexController@post')-&gt;name('index.post');\r\n<\/pre>\n<p>Controller\u3067\u306f\u3001\u547c\u3073\u51fa\u3055\u308c\u305f\u3089\u30ed\u30b0\u3092\u51fa\u529b\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304f\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n    public function post(Request $request)\r\n    {\r\n        \\Log::debug('IndexController@post');\r\n        \\Log::debug($request);\r\n        return redirect()-&gt;route('top');\r\n    }\r\n<\/pre>\n<p>blade\u306bform\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n    &lt;form method=&quot;post&quot; action=&quot;{{ route('index.post') }}&quot;&gt;\r\n    &lt;input type=&quot;text&quot; name=&quot;hoge&quot; \/&gt;\r\n    &lt;input type=&quot;submit&quot; value=&quot;\u9001\u4fe1&quot; \/&gt;\r\n    &lt;\/form&gt;\r\n<\/pre>\n<p>\u3053\u308c\u3067\u52d5\u304b\u3057\u3066\u307f\u3066\u3082\u3001storage\/logs\/laravel.log \u306b IndexController@post \u3067\u30ed\u30b0\u51fa\u529b\u3057\u3066\u3044\u308b\u306f\u305a\u304c\u3001\u4f55\u3082\u6b8b\u3089\u306a\u3044\u3002<\/p>\n<p>\u306a\u305c\u3063\uff01\uff01<\/p>\n<p>route\/web.php \u306bget\u30e1\u30bd\u30c3\u30c9\u3067\u306e\u30a2\u30af\u30bb\u30b9\u3082\u8ffd\u52a0\u3057\u3066\u307f\u305f\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nRoute::post('\/hoge', 'IndexController@post')-&gt;name('index.post');\r\nRoute::get('\/hoge', 'IndexController@post')-&gt;name('index.post');\r\n<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u3067URL\u3092\u76f4\u63a5\u6307\u5b9a\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u305f\u3089\u3001\u30ed\u30b0\u306b\u51fa\u529b\u3055\u308c\u305f\u3002<\/p>\n<p>get\u3067\u306f\u52d5\u304f\u306e\u306b\u3001post\u3067\u306f\u52d5\u304b\u306a\u3044\u3002<\/p>\n<p>\u306f\u3066\uff1f<\/p>\n<p>\u3057\u3070\u3089\u304f\u8003\u3048\u3066\u6c17\u4ed8\u3044\u305f\u3002<\/p>\n<p>@csrf\u3092\u66f8\u304d\u5fd8\u308c\u3066\u3044\u305f\u3002<\/p>\n<pre class=\"brush: php; highlight: [2]; title: ; notranslate\" title=\"\">\r\n    &lt;form method=&quot;post&quot; action=&quot;{{ route('index.post') }}&quot;&gt;\r\n    @csrf\r\n    &lt;input type=&quot;text&quot; name=&quot;hoge&quot; \/&gt;\r\n    &lt;input type=&quot;submit&quot; value=&quot;\u9001\u4fe1&quot; \/&gt;\r\n    &lt;\/form&gt;\r\n<\/pre>\n<p>\u3053\u308c\u3067\u7121\u4e8b\u306b post \u304c\u52d5\u304f\u3088\u3046\u306b\u306a\u3063\u305f\u3002<\/p>\n<p>Ajax\u3067post\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u304d\u306b\u3082\u5fd8\u308c\u304c\u3061\u3002<br \/>\n\u307e\u305a\u3001head\u30bf\u30b0\u5185\u306bCSRF\u30c8\u30fc\u30af\u30f3\u3092\u7528\u610f\u3057\u3066\u304a\u304f\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n    &lt;meta name=&quot;csrf-token&quot; content=&quot;{{ csrf_token() }}&quot;&gt;\r\n<\/pre>\n<p>\u3067\u3001Ajax\u90e8\u5206\u306f\u3053\u3061\u3089\u3002<br \/>\n\u3053\u308c\u3092\u66f8\u3044\u3068\u304b\u306a\u3044\u3068post\u304c\u52d5\u3044\u305f\u3088\u3046\u306b\u898b\u305b\u304b\u3051\u3066\u52d5\u3044\u3066\u306a\u3044\u3002<\/p>\n<pre class=\"brush: xml; highlight: [3,4,5,6,7]; title: ; notranslate\" title=\"\">\r\n    let url = 'hoge';\r\n    let data = 'hoge';\r\n    $.ajaxSetup({\r\n      headers: {\r\n        'X-CSRF-TOKEN': $('meta&#x5B;name=&quot;csrf-token&quot;]').attr('content')\r\n      }\r\n    });\r\n    $.ajax({\r\n      url: url,\r\n      method: 'post',\r\n      data: data,\r\n    })\r\n    .then(function(data) {\r\n      console.log(data);\r\n    });\r\n<\/pre>\n<div id=\"rinkerid104\" class=\"yyi-rinker-contents  yyi-rinker-postid-104 yyi-rinker-img-m yyi-rinker-catid-3 \">\n\t<div class=\"yyi-rinker-box\">\n\t\t<div class=\"yyi-rinker-image\">\n\t\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/4802613008?tag=satoshis-22&#038;linkCode=ogi&#038;th=1&#038;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-tracking\"  data-click-tracking=\"amazon_img 104 PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc\" data-vars-click-id=\"amazon_img 104 PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/m.media-amazon.com\/images\/I\/514Lk1-4TCS._SL160_.jpg\"  width=\"125\" height=\"160\" class=\"yyi-rinker-main-img\" style=\"border: none;\"><\/a>\t\t\t\t\t<\/div>\n\t\t<div class=\"yyi-rinker-info\">\n\t\t\t<div class=\"yyi-rinker-title\">\n\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/4802613008?tag=satoshis-22&#038;linkCode=ogi&#038;th=1&#038;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-tracking\" data-click-tracking=\"amazon_title 104 PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc\" data-vars-amp-click-id=\"amazon_title 104 PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc\" >PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc<\/a>\t\t\t\t\t\t\t<\/div>\n\t\t\t<div class=\"yyi-rinker-detail\">\n\t\t\t\t\t\t\t<div class=\"credit-box\">created by&nbsp;<a href=\"https:\/\/oyakosodate.com\/rinker\/\" rel=\"nofollow noopener\" target=\"_blank\" >Rinker<\/a><\/div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"price-box\">\n\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<ul class=\"yyi-rinker-links\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t                    <li class=\"amazonlink\">\n\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/4802613008?tag=satoshis-22&amp;linkCode=ogi&amp;th=1&amp;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-link yyi-rinker-tracking\"  data-click-tracking=\"amazon 104 PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc\"  data-vars-amp-click-id=\"amazon 104 PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc\">Amazon<\/a>\t\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<li class=\"rakutenlink\">\n\t\t\t\t\t\t<a href=\"https:\/\/hb.afl.rakuten.co.jp\/hgc\/0660286f.3d35f3ee.06602870.8701016f\/Rinker_o_20210521160855?pc=https%3A%2F%2Fsearch.rakuten.co.jp%2Fsearch%2Fmall%2Flaravel%2F%3Ff%3D1%26grp%3Dproduct&amp;m=https%3A%2F%2Fsearch.rakuten.co.jp%2Fsearch%2Fmall%2Flaravel%2F%3Ff%3D1%26grp%3Dproduct\" rel=\"nofollow\" class=\"yyi-rinker-link yyi-rinker-tracking\"  data-click-tracking=\"rakuten 104 PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc\"  data-vars-amp-click-id=\"rakuten 104 PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc\">\u697d\u5929\u5e02\u5834<\/a>\t\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<li class=\"yahoolink\">\n\t\t\t\t\t\t<a href=\"https:\/\/shopping.yahoo.co.jp\/search?p=laravel\" rel=\"nofollow\" class=\"yyi-rinker-link yyi-rinker-tracking\"  data-click-tracking=\"yahoo 104 PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc\"  data-vars-amp-click-id=\"yahoo 104 PHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af Laravel Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a \u30d0\u30fc\u30b8\u30e7\u30f38.x\u5bfe\u5fdc\">Yahoo\u30b7\u30e7\u30c3\u30d4\u30f3\u30b0<\/a>\t\t\t\t\t<\/li>\n\t\t\t\t                \t\t\t\t\t\t\t\t\t\t\t<\/ul>\n\t\t\t\t\t<\/div>\n\t<\/div>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Laravel\u3067POST\u3057\u3066\u3082Controller\u304c\u547c\u3073\u51fa\u3055\u308c\u306a\u304f\u3066\u3001\u3061\u3087\u3063\u3068\u30cf\u30de\u3063\u305f\u8a71\u3002 route\/web.php\u306b\u306f\u3001\u304d\u3061\u3093\u3068\u66f8\u3044\u3066\u3042\u308b\u3002 Route::post(&#8216;\/hoge&#8217;, &#8216;Index &#8230; <\/p>\n","protected":false},"author":1,"featured_media":63,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[23,22,14],"class_list":["post-62","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-blade","tag-csrf","tag-laravel"],"nelio_content":{"autoShareEndMode":"never","automationSources":{"useCustomSentences":false,"customSentences":[]},"efiAlt":"","efiUrl":"","followers":[1],"highlights":[],"isAutoShareEnabled":true,"networkImageIds":[],"permalinkQueryArgs":[],"series":[],"suggestedReferences":[]},"views":9961,"_links":{"self":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=62"}],"version-history":[{"count":4,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":105,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions\/105"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/media\/63"}],"wp:attachment":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}