{"id":1783,"date":"2018-10-26T23:42:13","date_gmt":"2018-10-26T14:42:13","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=1783"},"modified":"2018-10-26T23:42:13","modified_gmt":"2018-10-26T14:42:13","slug":"laravel-vue-%e3%81%a7%e5%95%8f%e3%81%84%e5%90%88%e3%82%8f%e3%81%9b%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%82%92%e3%81%a4%e3%81%8f%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=1783","title":{"rendered":"Laravel + Vue \u3067\u554f\u3044\u5408\u308f\u305b\u30d5\u30a9\u30fc\u30e0\u3092\u3064\u304f\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u30a6\u30a7\u30d6\u958b\u767a\u3092\u3057\u3066\u3044\u308b\u3068\u3088\u304f\u5fc5\u8981\u306b\u306a\u308b\u6a5f\u80fd\u306e\u3072\u3068\u3064\u306b<strong>\u304a\u554f\u3044\u5408\u308f\u305b\u30d5\u30a9\u30fc\u30e0<\/strong>\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3055\u3093\u3060\u3051\u304c\u5229\u7528\u3059\u308b\u30bf\u30a4\u30d7\u306e\u30b5\u30a4\u30c8\u306a\u3089\u4e0d\u8981\u3067\u3059\u304c\u3001\u305d\u308c\u4ee5\u5916\u306f\u3060\u3044\u305f\u3044\u3069\u306e\u3088\u3046\u306a\u30b5\u30a4\u30c8\u3067\u3082\u30e6\u30fc\u30b6\u30fc\u304c\u904b\u55b6\u8005\u306b\u9023\u7d61\u304c\u3067\u304d\u308b\u3088\u3046\u304a\u554f\u3044\u5408\u308f\u305b\u30d5\u30a9\u30fc\u30e0\u3092\u958b\u8a2d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u4eca\u56de\u306f\u6bd4\u8f03\u7684\u3054\u8981\u671b\u304c\u591a\u3044\u304a\u554f\u3044\u5408\u308f\u305b\u30d5\u30a9\u30fc\u30e0\u3092 <code>Larave<\/code> + <code>Vue<\/code>\u3067\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u3044\u3064\u3082\u306e\u5185\u5bb9\u3088\u308a\u57fa\u672c\u7684\u306a\u5185\u5bb9\u304c\u591a\u304f\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u305c\u3072\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u306d\u3002\uff08\u6700\u5f8c\u306b\u4eca\u56de\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\uff01\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1785 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/15-2.png\" alt=\"\" width=\"226\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/15-2.png 226w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/15-2-212x300.png 212w\" sizes=\"auto, (max-width: 226px) 100vw, 226px\" \/><\/p>\n<p>\u958b\u767a\u74b0\u5883\uff1a Laravel 5.7<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u4eca\u56de\u958b\u767a\u3059\u308b\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u304a\u554f\u3044\u5408\u308f\u305b\u30d5\u30a9\u30fc\u30e0\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u554f\u3044\u5408\u308f\u305b\u5185\u5bb9\u3092\u30e1\u30fc\u30eb\u3067\u9001\u4fe1<\/li>\n<li>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\uff08\u5165\u529b\u30c1\u30a7\u30c3\u30af\uff09\u3092\u3059\u308b<\/li>\n<li>Ajax\u901a\u4fe1\u3067\u9001\u4fe1\uff08\u30da\u30fc\u30b8\u306e\u79fb\u52d5\u306f\u306a\u3057\uff09<\/li>\n<\/ul>\n<p>\u3067\u306f\u5b9f\u969b\u306b\u958b\u767a\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<h1>\u304a\u554f\u3044\u5408\u308f\u305b\u306e\u5165\u529b\u30da\u30fc\u30b8\u3092\u3064\u304f\u308b\uff08\u30c7\u30b6\u30a4\u30f3\u90e8\u5206\uff09<\/h1>\n<h2>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u3064\u304f\u308b<\/h2>\n<p>\u4eca\u56de\u5fc5\u8981\u306a\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u4ee5\u4e0b\u306e\uff12\u3064\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u304a\u554f\u3044\u5408\u308f\u305b\u306e\u5165\u529b\u30da\u30fc\u30b8<\/li>\n<li>Ajax\u3067\u304a\u554f\u3044\u5408\u308f\u305b\u5185\u5bb9\u3092\u53d7\u4fe1\u3059\u308b\u30da\u30fc\u30b8<\/li>\n<\/ul>\n<p>\u305d\u306e\u305f\u3081\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5185\u5bb9\u3092\u8ffd\u52a0\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>Route::get('contact', 'ContactController@input');<\/strong> \/\/ \u5165\u529b\u30da\u30fc\u30b8\r\n<strong>Route::post('contact', 'ContactController@send');<\/strong> \/\/ \u9001\u4fe1\u30da\u30fc\u30b8\uff08Ajax\uff09<\/pre>\n<p>\u203b \u672c\u6765\u306fHTTP\u3068Ajax\u306a\u306e\u3067\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306f\u5206\u3051\u308b\u65b9\u304c\u3044\u3044\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u8aac\u660e\u306e\u305f\u3081\u30b7\u30f3\u30d7\u30eb\u306b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306f\u3072\u3068\u3064\u3060\u3051\u3067\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001\u6b21\u306b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>php artisan make:controller ContactController<\/strong><\/pre>\n<p>\u3053\u308c\u3067<code>app\/Http\/Controllers\/ContactController.php<\/code>\u304c\u4f5c\u6210\u3055\u308c\u307e\u3057\u305f\u3002<br \/>\n\u306a\u304a\u3001\u4eca\u306e\u6bb5\u968e\u3067\u306f\u3001\u5165\u529b\u30da\u30fc\u30b8\u306e\u305f\u3081\u306b<code>input()<\/code>\u3060\u3051\u3092\u4f5c\u6210\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse Illuminate\\Http\\Request;\r\n\r\nclass ContactController extends Controller\r\n{\r\n<strong>    public function input() {<\/strong>\r\n\r\n<strong>        return view('contact.input');<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<h2>\u30d3\u30e5\u30fc\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>\u7d9a\u3044\u3066\u306f\u3001\u5b9f\u969b\u306b\u30e6\u30fc\u30b6\u30fc\u304c\u76ee\u306b\u3059\u308b\u30d3\u30e5\u30fc\u3067\u3059\u3002<br \/>\n<code>resources\/views\/contact\/input.blade.php<\/code>\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u203b \u306a\u304a\u3001\u4eca\u56de\u306f\u3044\u3064\u3082\u306e<code>bootstrap<\/code>\u3067\u306f\u306a\u304f<a href=\"https:\/\/foundation.zurb.com\/\" target=\"_blank\" rel=\"noopener\">Zurb Foundation<\/a>\u3092\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002<a href=\"https:\/\/bootsnipp.com\/foundation\/snippets\/featured\/foundation-form\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089<\/a>\u306e\u30c7\u30b6\u30a4\u30f3\u3092\u4f7f\u308f\u305b\u3066\u3082\u3089\u3044\u307e\u3057\u305f\u3002m_ _m<\/p>\n<pre>&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;link href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/foundation\/6.3.1\/css\/foundation.min.css\" rel=\"stylesheet\" id=\"bootstrap-css\"&gt;\r\n    &lt;style&gt;\r\n\r\n        .error_txt{margin-bottom: 10px; display: block; color: #f00; font-size: 13px;}\r\n\r\n        .foundation-example__ex-wrapper{\r\n            background-color: lightblue;\r\n        }\r\n        .foundation-example__in-wrapper{\r\n            margin: auto;\r\n            max-width: 960px;\r\n            background: white;\r\n            padding: 30px;\r\n        }\r\n\r\n        .foundation-example__title{\r\n            font-size: 40px;\r\n            margin-bottom: 25px;\r\n        }\r\n\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;section&gt;\r\n        &lt;div style=\"height: 50px;background: lightblue;\"&gt;&lt;\/div&gt;\r\n        &lt;div class=\"foundation-example__ex-wrapper\"&gt;\r\n            &lt;div class=\"foundation-example__in-wrapper\"&gt;\r\n                &lt;div class=\"foundation-example__title\"&gt; \u304a\u554f\u3044\u5408\u308f\u305b&lt;\/div&gt;\r\n                &lt;form&gt;\r\n                    &lt;div class=\"row\"&gt;\r\n                        &lt;div class=\"large-6 columns\"&gt;\r\n                            &lt;label&gt;\u540d\r\n                                &lt;input type=\"text\"&gt;\r\n                                &lt;div class=\"error_txt\"&gt;&lt;\/div&gt;\r\n                            &lt;\/label&gt;\r\n                            &lt;label&gt;\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\r\n                                &lt;input type=\"text\"&gt;\r\n                                &lt;div class=\"error_txt\"&gt;&lt;\/div&gt;\r\n                            &lt;\/label&gt;\r\n                        &lt;\/div&gt;\r\n\r\n                        &lt;div class=\"large-6 columns\"&gt;\r\n                            &lt;label&gt;\u59d3\r\n                                &lt;input type=\"text\"&gt;\r\n                                &lt;div class=\"error_txt\"&gt;&lt;\/div&gt;\r\n                            &lt;\/label&gt;\r\n                            &lt;label&gt;\u3054\u7528\u4ef6\r\n                                &lt;select&gt;&lt;\/select&gt;\r\n                                &lt;div class=\"error_txt&gt;&lt;\/div&gt;\r\n                            &lt;\/label&gt;\r\n                        &lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                    &lt;div class=\"row\"&gt;\r\n                        &lt;div class=\"large-12 columns\"&gt;\r\n                            &lt;label&gt;\u304a\u554f\u3044\u5408\u308f\u305b\u5185\u5bb9\r\n                                &lt;textarea rows=\"10\" placeholder=\"\u304a\u554f\u3044\u5408\u308f\u305b\u306e\u5185\u5bb9\u3092\u3054\u5165\u529b\u304f\u3060\u3055\u3044\u3002\"&gt;&lt;\/textarea&gt;\r\n                                &lt;div class=\"error_txt&gt;&lt;\/div&gt;\r\n                            &lt;\/label&gt;\r\n                        &lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                    &lt;div class=\"row\"&gt;\r\n                        &lt;div class=\"large-12 columns text-center\"&gt;\r\n                            &lt;button class=\"button expanded\" type=\"button\"&gt;\u9001\u4fe1\u3059\u308b&lt;\/button&gt;\r\n                        &lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                &lt;\/form&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n        &lt;div style=\"height: 50px;background: lightblue;\"&gt;&lt;\/div&gt;\r\n    &lt;\/section&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u3067\u306f\u3001\u30da\u30fc\u30b8\u3092\u958b\u3044\u3066\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1803\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_form.png\" alt=\"\" width=\"1018\" height=\"663\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_form.png 1018w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_form-300x195.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_form-768x500.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>\u3067\u306f\u3001\u6b21\u306e\u9805\u76ee\u304b\u3089\u3053\u306e\u30d5\u30a9\u30fc\u30e0\u3067\u554f\u3044\u5408\u308f\u305b\u30d5\u30a9\u30fc\u30e0\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002\uff08<code>Foundation<\/code>\u3082\u304d\u308c\u3044\u306a\u30c7\u30b6\u30a4\u30f3\u306b\u306a\u308a\u307e\u3059\u306d\uff01 ^^\uff09<\/p>\n<h1>\u304a\u554f\u3044\u5408\u308f\u305b\u306e\u5165\u529b\u30da\u30fc\u30b8\u3092\u3064\u304f\u308b\uff08JavaScript\u90e8\u5206\uff09<\/h1>\n<h2>Vue\u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b<\/h2>\n<p>\u307e\u305a\u3001Vue\u3092\u4f7f\u3048\u308b\u3088\u3046\u306bcdn\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u57fa\u672c\u5f62\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>&lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue@2.5.17\/dist\/vue.min.js\"&gt;&lt;\/script&gt;<\/strong>\r\n&lt;script&gt;\r\n\r\n<strong>    new Vue({<\/strong>\r\n<strong>        el: '#app'<\/strong>\r\n<strong>    });<\/strong>\r\n\r\n&lt;\/script&gt;<\/pre>\n<p>\u305d\u3057\u3066\u3001Vue\u304c\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30a8\u30ea\u30a2\u306b<code>id<\/code>\u3092\u8ffd\u52a0\u3002<\/p>\n<pre>&lt;section <strong>id=\"app\"<\/strong>&gt;\r\n&lt;!-- \u7701\u7565 --&gt;\r\n&lt;\/section&gt;<\/pre>\n<h2>\u30c7\u30fc\u30bf\u5909\u6570\u3092\u3064\u304f\u3063\u3066\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3059\u308b<\/h2>\n<p>\u307e\u305a\u306f\u3001<code>data<\/code>\u306b\u6b21\u306e\u3088\u3046\u306a\u5909\u6570\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>new Vue({\r\n    el: '#app',\r\n    <strong>data: {<\/strong>\r\n<strong>        firstName: '',<\/strong>\r\n<strong>        lastName: '',<\/strong>\r\n<strong>        email: '',<\/strong>\r\n<strong>        subjectId: '',<\/strong>\r\n<strong>        body: '',<\/strong>\r\n<strong>        subjects: {<\/strong>\r\n<strong>            100: '\u5546\u54c1\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',<\/strong>\r\n<strong>            200: '\u304a\u652f\u6255\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',<\/strong>\r\n<strong>            300: '\u30b7\u30e7\u30c3\u30d4\u30f3\u30b0\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',<\/strong>\r\n<strong>            400: '\u30dd\u30a4\u30f3\u30c8\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',<\/strong>\r\n<strong>            500: '\u3054\u8cea\u554f\u30fb\u305d\u306e\u4ed6',<\/strong>\r\n<strong>        }<\/strong>\r\n<strong>    }<\/strong>\r\n});<\/pre>\n<p>\u305d\u3057\u3066\u3001\u5404<code>&lt;input&gt;<\/code>\u3001<code>&lt;select&gt;<\/code>\u3001<code>&lt;textarea&gt;<\/code>\u30bf\u30b0\u306b<code>v-model<\/code>\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;label&gt;\u59d3\r\n    &lt;input type=\"text\" <strong>v-model=\"lastName\"<\/strong>&gt;\r\n&lt;!--\u7701\u7565--&gt;\r\n\r\n&lt;label&gt;\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\r\n    &lt;input type=\"text\" <strong>v-model=\"email\"<\/strong>&gt;\r\n&lt;!--\u7701\u7565--&gt;\r\n\r\n&lt;label&gt;\u540d\r\n    &lt;input type=\"text\" <strong>v-model=\"firstName\"<\/strong>&gt;\r\n&lt;!--\u7701\u7565--&gt;\r\n\r\n&lt;label&gt;\u3054\u7528\u4ef6\r\n    &lt;select <strong>v-model=\"subjectId\"<\/strong>&gt;&lt;\/select&gt;\r\n&lt;!--\u7701\u7565--&gt;\r\n\r\n&lt;label&gt;\u304a\u554f\u3044\u5408\u308f\u305b\u5185\u5bb9\r\n    &lt;textarea rows=\"10\" placeholder=\"\u304a\u554f\u3044\u5408\u308f\u305b\u306e\u5185\u5bb9\u3092\u3054\u5165\u529b\u304f\u3060\u3055\u3044\u3002\" <strong>v-model=\"body\"<\/strong>&gt;&lt;\/textarea&gt;<\/pre>\n<p>\u3053\u308c\u3067\u3001\u5165\u529b\u5185\u5bb9\u5909\u66f4\u306b\u306a\u308b\u3068\u540c\u6642\u306bVue\u306e\u5909\u6570\u3082\u81ea\u52d5\u7684\u306b\u66f4\u65b0\u3055\u308c\u307e\u3059\u3002\uff08\u3053\u308c\u304c\u3001\u30c7\u30fc\u30bf\u30fb\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\uff09<\/p>\n<p>\u305d\u3057\u3066\u3001\u300c\u3054\u7528\u4ef6\u300d\u306e\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u3067\u3059\u304c\u3001\u307e\u3060\u9078\u629e\u80a2\u304c\u7121\u3044\u306e\u3067\u3053\u308c\u3082Vue\u3067\u6e96\u5099\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>&lt;select v-model=\"subjectId\"&gt;\r\n    <strong>&lt;option value=\"\"&gt;&lt;\/option&gt;<\/strong>\r\n<strong>    &lt;option v-for=\"(subject,id) in subjects\" :value=\"id\" v-text=\"subject\"&gt;&lt;\/option&gt;<\/strong>\r\n&lt;\/select&gt;<\/pre>\n<p>\u672a\u9078\u629e\u306e\u5834\u5408\u306f\u7a7a\u767d\u306b\u3057\u3066\u304a\u304d\u305f\u3044\u306e\u3067\u3001\uff11\u884c\u76ee\u306e<code>&lt;option&gt;<\/code>\u306fvalue\u304c\u7a7a\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\uff12\u884c\u76ee\u306f<code>v-for<\/code>\u3092\u4f7f\u3063\u3066\u5148\u307b\u3069<code>data<\/code>\u306b\u66f8\u3044\u305f<code>subjects<\/code>\u3092\u30eb\u30fc\u30d7\u3057\u3001<code>value<\/code>\u3068\u8868\u793a\u5185\u5bb9\u3092\u30bb\u30c3\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3092Vue\u306b\u8868\u793a\u3055\u305b\u308b\u3068\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>&lt;select&gt;\r\n    &lt;option value=\"\"&gt;&lt;\/option&gt;\r\n    <strong>&lt;option value=\"100\"&gt;\u5546\u54c1\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f&lt;\/option&gt;<\/strong>\r\n<strong>    &lt;option value=\"200\"&gt;\u304a\u652f\u6255\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f&lt;\/option&gt;<\/strong>\r\n<strong>    &lt;option value=\"300\"&gt;\u30b7\u30e7\u30c3\u30d4\u30f3\u30b0\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f&lt;\/option&gt;<\/strong>\r\n<strong>    &lt;option value=\"400\"&gt;\u30dd\u30a4\u30f3\u30c8\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f&lt;\/option&gt;<\/strong>\r\n<strong>    &lt;option value=\"500\"&gt;\u3054\u8cea\u554f\u30fb\u305d\u306e\u4ed6&lt;\/option&gt;<\/strong>\r\n&lt;\/select&gt;<\/pre>\n<p>\u3067\u306f\u5b9f\u969b\u306b\u3046\u307e\u304f\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1805 size-full\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-25-05-35-31.png\" alt=\"\" width=\"495\" height=\"450\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-25-05-35-31.png 495w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-25-05-35-31-300x273.png 300w\" sizes=\"auto, (max-width: 495px) 100vw, 495px\" \/><\/p>\n<p>\u3046\u307e\u304f\u3044\u304d\u307e\u3057\u305f\uff01<\/p>\n<h2>Ajax\u3067\u9001\u4fe1\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001\u9001\u4fe1\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u5f8c\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002\uff08IE11\u306e\u3053\u3068\u3082\u8003\u3048\u3066ES\uff16\u306f\u4f7f\u308f\u306a\u3044\u3067\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3057\u3066\u3044\u307e\u3059 ^^;\uff09<\/p>\n<p>\u307e\u305a\u3001Ajax\u901a\u4fe1\u304c\u3067\u304d\u308b\u3088\u3046\u306b<code>axios<\/code>\u3068\u3044\u3046JS\u30e9\u30a4\u30d6\u30e9\u30ea\u3092<code>cdn<\/code>\u304b\u3089\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n<pre><strong>&lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/axios\/0.18.0\/axios.min.js\"&gt;&lt;\/script&gt;<\/strong><\/pre>\n<p>\u6b21\u306b\u9001\u4fe1\u30dc\u30bf\u30f3\u306b\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u3001<code>onSubmit()<\/code>\u3092\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;text class=\"button\" type=\"text\" <strong>@click=\"onSubmit()\"<\/strong>&gt;\u9001\u4fe1\u3059\u308b&lt;\/text&gt;<\/pre>\n<p><code>onSubmit()<\/code>\u306e\u4e2d\u8eab\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>methods: {\r\n    <strong>onSubmit: function() {<\/strong>\r\n\r\n        if(!confirm('\u9001\u4fe1\u3057\u307e\u3059\u3002\u3088\u308d\u3057\u3044\u3067\u3059\u304b\uff1f')) {\r\n\r\n            return;\r\n\r\n        }\r\n\r\n        var params = {\r\n            first_name: this.firstName,\r\n            last_name: this.lastName,\r\n            email: this.email,\r\n            subject_id: this.subjectId,\r\n            body: this.body\r\n        };\r\n<strong>        axios.post('\/contact', params)<\/strong>\r\n<strong>            .then(function(response){<\/strong>\r\n\r\n<strong>                \/\/ \u6210\u529f\u3057\u305f\u6642<\/strong>\r\n\r\n<strong>            })<\/strong>\r\n<strong>            .catch(function(error){<\/strong>\r\n\r\n<strong>                \/\/ \u5931\u6557\u3057\u305f\u3068\u304d<\/strong>\r\n\r\n<strong>            });<\/strong>\r\n\r\n    <strong>}<\/strong>\r\n}<\/pre>\n<h2>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u5f8c\u3067\u5fc5\u8981\u306b\u306a\u308b\u306e\u3067\u3001Ajax\u3067\u53d7\u4fe1\u3092\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b\u524d\u306b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\uff08\u5165\u529b\u30c1\u30a7\u30c3\u30af\uff09\u3092\u4f5c\u3063\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067\u5c02\u7528\u306e<code>Request<\/code>\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>php artisan make:request ContactRequest<\/strong><\/pre>\n<p>\u305d\u3057\u3066\u3001\u3053\u3053\u306b\u5165\u529b\u30c1\u30a7\u30c3\u30af\u30fb\u30eb\u30fc\u30eb\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002\uff08\u592a\u5b57\u306e\u90e8\u5206\u304c\u5909\u66f4\u3057\u305f\u5834\u6240\u3067\u3059\uff09<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Requests;\r\n\r\nuse Illuminate\\Foundation\\Http\\FormRequest;\r\n\r\nclass ContactRequest extends FormRequest\r\n{\r\n    \/**\r\n     * Determine if the user is authorized to make this request.\r\n     *\r\n     * @return bool\r\n     *\/\r\n    public function authorize()\r\n    {\r\n        return <strong>true<\/strong>;\r\n    }\r\n\r\n    \/**\r\n     * Get the validation rules that apply to the request.\r\n     *\r\n     * @return array\r\n     *\/\r\n    public function rules()\r\n    {\r\n        <strong>return [<\/strong>\r\n<strong>            'first_name' =&gt; 'required',<\/strong>\r\n<strong>            'last_name' =&gt; 'required',<\/strong>\r\n<strong>            'email' =&gt; 'required|email',<\/strong>\r\n<strong>            'subject_id' =&gt; 'required|in:100,200,300,400,500',<\/strong>\r\n<strong>            'body' =&gt; 'required'<\/strong>\r\n<strong>        ];<\/strong>\r\n    }\r\n}<\/pre>\n<p>\u203b \u672c\u6765\u306f<code>subject_id<\/code>\u306e<code>in<\/code>\u306f\u4e00\u5143\u7ba1\u7406\u3057\u305f\u30c7\u30fc\u30bf\u304b\u3089\u547c\u3073\u51fa\u3059\u3079\u304d\uff08Vue\u90e8\u5206\u3082\uff09\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u5206\u304b\u308a\u3084\u3059\u3044\u8aac\u660e\u306e\u305f\u3081\u306b\u76f4\u66f8\u304d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001\u3053\u306e\u307e\u307e\u3067\u306f\u30a8\u30e9\u30fc\u5185\u5bb9\u306f\u82f1\u8a9e\u306e\u307f\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001<code>resources\/lang\/ja\/validation.php<\/code>\u3092\u4f5c\u6210\u3057\u3066\u3001<a href=\"https:\/\/github.com\/caouecs\/Laravel-lang\/tree\/master\/src\/ja\" target=\"_blank\" rel=\"noopener\">Laravel-lang<\/a>\uff08\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u7ffb\u8a33\uff09\u306e\u5185\u5bb9\u3092\u30b3\u30d4\u30fc\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3055\u3089\u306b\u4e00\u756a\u4e0b\u306e<code>attributes<\/code>\u306b\u5165\u529b\u5024\u306e\u540d\u524d\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>'attributes' =&gt; [<\/strong>\r\n<strong>    'first_name' =&gt; '\u540d',<\/strong>\r\n<strong>    'last_name' =&gt; '\u59d3',<\/strong>\r\n<strong>    'email' =&gt; '\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9',<\/strong>\r\n<strong>    'subject_id' =&gt; '\u3054\u7528\u4ef6',<\/strong>\r\n<strong>    'body' =&gt; '\u304a\u554f\u3044\u5408\u308f\u305b\u5185\u5bb9'<\/strong>\r\n<strong>],<\/strong><\/pre>\n<h2>\u30e1\u30fc\u30eb\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>Laravel\u306b\u306f<code>Mailable<\/code>\u3068\u3044\u3046\u30af\u30e9\u30b9\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u3066\u3001\u3053\u308c\u3092\u5229\u7528\u3059\u308b\u3068\u7c21\u5358\u306b\u30e1\u30fc\u30eb\u9001\u4fe1\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067<code>Contacted<\/code>\u3068\u3044\u3046\u540d\u524d\u306e<code>Mailable<\/code>\u30af\u30e9\u30b9\u3092\u3064\u304f\u308a\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>php artisan make:mail Contacted<\/strong><\/pre>\n<p>\u4f5c\u6210\u3055\u308c\u305f<code>app\/Mail\/Contacted.php<\/code>\u3092\u958b\u3044\u3066\u3001\u4e2d\u8eab\u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Mail;\r\n\r\nuse Illuminate\\Bus\\Queueable;\r\nuse Illuminate\\Mail\\Mailable;\r\nuse Illuminate\\Queue\\SerializesModels;\r\nuse Illuminate\\Contracts\\Queue\\ShouldQueue;\r\n\r\nclass Contacted extends Mailable\r\n{\r\n    use Queueable, SerializesModels;\r\n\r\n    <strong>private $_params = [];<\/strong>\r\n\r\n    \/**\r\n     * Create a new message instance.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function __construct(<strong>$params<\/strong>)\r\n    {\r\n        <strong>$this-&gt;_params = $params;<\/strong>\r\n    }\r\n\r\n    \/**\r\n     * Build the message.\r\n     *\r\n     * @return $this\r\n     *\/\r\n    public function build()\r\n    {\r\n<strong>        return $this<\/strong><strong>-&gt;subject('\u304a\u554f\u3044\u5408\u308f\u305b\u304c\u3042\u308a\u307e\u3057\u305f')<\/strong>\r\n<strong>            -&gt;with('params', $this-&gt;_params)<\/strong>\r\n<strong>            -&gt;view('mail.contact');<\/strong>\r\n    }\r\n}<\/pre>\n<p>\u3055\u3089\u306b\u3001\u307e\u3060<code>mail.contact<\/code>\u3068\u3044\u3046\u30d3\u30e5\u30fc\u304c\u306a\u3044\u306e\u3067\u3001<code>resources\/views\/mail\/contact.blade.php<\/code>\u3092\u4f5c\u6210\u3057\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>\u4ee5\u4e0b\u306e\u304a\u554f\u3044\u5408\u308f\u305b\u3092\u53d7\u3051\u4ed8\u3051\u307e\u3057\u305f\u3002&lt;br&gt;\r\n&lt;br&gt;&lt;br&gt;\r\n\u540d\u524d\uff1a {{ $params['last_name'] }} {{ $params['first_name'] }}&lt;br&gt;\r\n\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\uff1a {{ $params['email'] }}&lt;br&gt;\r\n\u3054\u7528\u4ef6\uff1a {{ $params['subject'] }}&lt;br&gt;\r\n\u304a\u554f\u3044\u5408\u308f\u305b\u5185\u5bb9\uff1a &lt;pre&gt;{{ $params['body'] }}&lt;\/pre&gt;\r\n\r\n<\/strong><\/pre>\n<h2>Ajax\u3067\u53d7\u4fe1\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u7d9a\u3044\u3066\u3001\u9001\u4fe1\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u53d7\u4fe1\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<br \/>\n\u3053\u3053\u304b\u3089\u306f\u3001Laravel\uff08PHP\uff09\u90e8\u5206\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5148\u307b\u3069\u4f5c\u3063\u305f<code>ContactController<\/code>\u3092\u958b\u3044\u3066<code>send()<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse App\\Http\\Requests\\ContactRequest;\r\nuse Illuminate\\Http\\Request;\r\n\r\nclass ContactController extends Controller\r\n{\r\n    \/\/ \u7701\u7565\r\n\r\n<strong>    public function send(ContactRequest $request) {<\/strong>\r\n\r\n<strong>        \/\/ \u3053\u3053\u3067\u30e1\u30fc\u30eb\u9001\u4fe1<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u3053\u3053\u3067\u3001\u5f15\u6570\u306e\u4e2d\u306b<code>ContactRequest<\/code>\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u81ea\u52d5\u7684\u306b\u5148\u307b\u3069\u4f5c\u3063\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u3001\u554f\u984c\u304c\u3042\u308c\u3070\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u30c6\u30b9\u30c8\u3067\u4f55\u3082\u5165\u529b\u305b\u305a\u306b\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3057\u3066\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u3069\u3046\u306a\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1797\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-25-17-15-10.png\" alt=\"\" width=\"616\" height=\"208\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-25-17-15-10.png 616w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-25-17-15-10-300x101.png 300w\" sizes=\"auto, (max-width: 616px) 100vw, 616px\" \/><\/p>\n<p>\u3046\u307e\u304f\u3044\u304d\u307e\u3057\u305f\u3002<br \/>\n\u30a8\u30e9\u30fc\u5185\u5bb9\u3082\u65e5\u672c\u8a9e\u5316\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u30e1\u30fc\u30eb\u9001\u4fe1\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u540c\u3058\u304f<code>ContactController<\/code>\u3092\u958b\u3044\u3066<code>send()<\/code>\u30e1\u30bd\u30c3\u30c9\u306b\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>public function send(ContactRequest $request) {\r\n\r\n    $subjects = [\r\n        '100' =&gt; '\u5546\u54c1\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',\r\n        '200' =&gt; '\u304a\u652f\u6255\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',\r\n        '300' =&gt; '\u30b7\u30e7\u30c3\u30d4\u30f3\u30b0\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',\r\n        '400' =&gt; '\u30dd\u30a4\u30f3\u30c8\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',\r\n        '500' =&gt; '\u3054\u8cea\u554f\u30fb\u305d\u306e\u4ed6',\r\n    ];\r\n    $params = [\r\n        'first_name' =&gt; $request-&gt;first_name,\r\n        'last_name' =&gt; $request-&gt;last_name,\r\n        'email' =&gt; $request-&gt;email,\r\n        'subject_id' =&gt; $request-&gt;subject_id,\r\n        'body' =&gt; $request-&gt;body,\r\n        'subject' =&gt; $subjects[$request-&gt;subject_id]\r\n    ];\r\n    <strong>\\Mail::to('admin@example.com')-&gt;send(new Contacted($params));<\/strong>\r\n}<\/pre>\n<p>\u203b \u3053\u3053\u3067\u3082\u8aac\u660e\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u306b<code>$subjects<\/code>\u306f\u76f4\u66f8\u304d\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3069\u3053\u304b\u3067\u5171\u901a\u30c7\u30fc\u30bf\u306b\u3059\u3079\u304d\u3067\u3059\u3002<\/p>\n<h2>\u30c6\u30b9\u30c8\u9001\u4fe1\u3059\u308b<\/h2>\n<p>\u3067\u306f\u3001\u4eca\u306e\u6642\u70b9\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5185\u5bb9\u3092\u5165\u529b\u3057\u3001\u30e1\u30fc\u30eb\u9001\u4fe1\u3067\u304d\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1789\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_form_2.png\" alt=\"\" width=\"956\" height=\"593\" \/><\/p>\n<p>\u3046\u307e\u304f\u3044\u3051\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u9001\u4fe1\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1790\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_email_1.png\" alt=\"\" width=\"372\" height=\"325\" \/><\/p>\n<h2>Ajax\u9001\u4fe1\u304c\u5931\u6557\u3057\u305f\u6642\u306e\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u6700\u5f8c\u306b\u3001\u5165\u529b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u3068\u304d\u306e\u8868\u793a\u3082\u5b9f\u88c5\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u3001<code>data<\/code>\u306b\u5404\u5165\u529b\u30a8\u30e9\u30fc\u304c\u5165\u308b<code>errors<\/code>\u3068\u3044\u3046\u5909\u6570\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<pre>data: {\r\n\r\n    \/\/ \u7701\u7565\r\n\r\n    <strong>errors: {}<\/strong>\r\n},<\/pre>\n<p>\u305d\u3057\u3066\u3001Ajax\u9001\u4fe1\u306e\u76f4\u524d\u306b\u5fc5\u305a\u521d\u671f\u5316\u3057\u3001\u30a8\u30e9\u30fc\u306e\u5834\u5408\u306e\u307f\u305d\u308c\u305e\u308c\u306e\u30a8\u30e9\u30fc\u5185\u5bb9\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>this.errors = {};<\/strong>\r\n\r\n\/\/ \u7701\u7565\r\n\r\naxios.post('\/contact', params)\r\n    .then(function(){\r\n\r\n        \/\/ \u7701\u7565\r\n\r\n    })\r\n    .catch(function(error){\r\n\r\n        <strong>var errors = {};<\/strong>\r\n\r\n<strong>        for(var key in error.response.data.errors) {<\/strong>\r\n\r\n<strong>            errors[key] = error.response.data.errors[key].join('&lt;br&gt;');<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        self.errors = errors;<\/strong>\r\n\r\n    });<\/pre>\n<p>\u203b \u306a\u304a\u3001\u4e00\u65e6\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u306e<code>errors<\/code>\u306b\u5168\u30a8\u30e9\u30fc\u3092\u683c\u7d0d\u3057\u3066\u3044\u308b\u306e\u306f\u3001Vue\u306f\u914d\u5217\u306e\u4e2d\u8eab\u304c\u5909\u66f4\u3055\u308c\u3066\u3082\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u81ea\u52d5\u5909\u66f4\u306f\u884c\u308f\u308c\u306a\u3044\u304b\u3089\u3067\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u6700\u5f8c\u306b\u4e00\u6c17\u306b\u30c7\u30fc\u30bf\u3092\u5909\u66f4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u3053\u306e\u30a8\u30e9\u30fc\u3092<code>v-html<\/code>\u3092\u4f7f\u3063\u3066\u305d\u308c\u305e\u308c\u306e\u4f4d\u7f6e\u3067\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>&lt;div class=\"error_txt\" <strong>v-html=\"errors.last_name\"<\/strong>&gt;&lt;\/div&gt;\r\n\r\n\/\/ \u7701\u7565\r\n\r\n&lt;div class=\"error_txt\" <strong>v-html=\"errors.email\"<\/strong>&gt;&lt;\/div&gt;\r\n\r\n\/\/ \u7701\u7565\r\n\r\n&lt;div class=\"error_txt\" <strong>v-html=\"errors.first_name\"<\/strong>&gt;&lt;\/div&gt;\r\n\r\n\/\/ \u7701\u7565\r\n\r\n&lt;div class=\"error_txt\" <strong>v-html=\"errors.subject_id\"<\/strong>&gt;&lt;\/div&gt;\r\n\r\n\/\/ \u7701\u7565\r\n\r\n&lt;div class=\"error_txt\" <strong>v-html=\"errors.body\"<\/strong>&gt;&lt;\/div&gt;<\/pre>\n<p>\u203b <code>&lt;br&gt;<\/code>\u30bf\u30b0\u304c\u5165\u3063\u3066\u304f\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u306e\u3067\u3042\u3048\u3066<code>v-html<\/code>\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30a8\u30e9\u30fc\u5185\u5bb9\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1798\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_form_4.png\" alt=\"\" width=\"955\" height=\"695\" \/><\/p>\n<h2>Ajax\u9001\u4fe1\u304c\u6210\u529f\u3057\u305f\u6642\u306e\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u9001\u4fe1\u304c\u5b8c\u4e86\u3057\u305f\u5834\u5408\u306b\u5165\u529b\u30d5\u30a9\u30fc\u30e0\u3092\u6d88\u3057\u3001\u300c\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u9001\u4fe1\u3055\u308c\u307e\u3057\u305f\u3002\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002\u300d\u3068\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u3001<code>data<\/code>\u306b\u30e1\u30fc\u30eb\u304c\u9001\u4fe1\u3055\u308c\u305f\u304b\u3069\u3046\u304b\u304c\u5206\u304b\u308b<code>emailSent<\/code>\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>data: {\r\n\r\n    \/\/ \u7701\u7565\r\n\r\n    <strong>emailSent: false<\/strong>\r\n},<\/pre>\n<p>\u305d\u3057\u3066\u3001\u30e1\u30fc\u30eb\u9001\u4fe1\u304c\u5b8c\u4e86\u3057\u305f\u6642\u70b9\u3067<code>emailSend<\/code>\u3092<code>true<\/code>\u306b\u5207\u308a\u66ff\u3048\u307e\u3059\u3002<\/p>\n<pre><strong>var self = this;<\/strong>\r\n\r\n\/\/ \u7701\u7565\r\n\r\naxios.post('\/contact', params)\r\n    .then(function(){\r\n\r\n        <strong>self.emailSent = true;<\/strong>\r\n\r\n    })\r\n    .catch(function(error){\r\n\r\n        \/\/ \u7701\u7565\r\n\r\n    });<\/pre>\n<p>\u203b \u95a2\u6570\u5185\u306f<code>this<\/code>\u304c\u9055\u3046\u5834\u6240\u3092\u6307\u3057\u3066\u3057\u307e\u3046\u306e\u3067\u3001<code>self<\/code>\u306b\u683c\u7d0d\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff08ES6\u306e\u30a2\u30ed\u30fc\u95a2\u6570\u304c\u4f7f\u3048\u3070\u7121\u8996\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001IE\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u306e\u3067\u3053\u3046\u306a\u308a\u307e\u3057\u305f ^^;\uff09<\/p>\n<p>\u305d\u3057\u3066\u3001Vue\u306e<code>v-if<\/code>\u3067\u8868\u793a\u306e\u5207\u308a\u66ff\u3048\u3067\u3059\u3002<br \/>\n\u307e\u305a<code>&lt;form&gt;<\/code>\u30bf\u30b0\u3092\u30e1\u30fc\u30eb\u304c\u9001\u4fe1\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u3060\u3051\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;form <strong>v-if=\"!emailSent\"<\/strong>&gt;<\/pre>\n<p>\u9006\u306b\u3001\u30e1\u30fc\u30eb\u304c\u9001\u4fe1\u3055\u308c\u305f\u5834\u5408\u306b\u306f\u5b8c\u4e86\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\uff08\u9593\u306b\u4f55\u3082\u5165\u308c\u308b\u4e88\u5b9a\u304c\u306a\u3044\u306a\u3089<code>v-else<\/code>\u3067\u3082\u3044\u3044\u3067\u3057\u3087\u3046\uff09<\/p>\n<pre>&lt;!-- \u7701\u7565 --&gt;\r\n\r\n&lt;\/form&gt;\r\n<strong>&lt;div v-if=\"emailSent\"&gt;\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u9001\u4fe1\u3055\u308c\u307e\u3057\u305f\u3002\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002&lt;\/div&gt;<\/strong><\/pre>\n<p>\u3053\u308c\u3067\u9001\u4fe1\u304c\u5b8c\u4e86\u3057\u305f\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1795\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_form_3.png\" alt=\"\" width=\"1011\" height=\"220\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_form_3.png 1011w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_form_3-300x65.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/contact_form_3-768x167.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<h1>\u304a\u307e\u3051<\/h1>\n<p>\u9014\u4e2d\u3067\u4f55\u5ea6\u304b\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u3084\u306f\u308a\u4ee5\u4e0b\u306e\u30c7\u30fc\u30bf\u306f\u3069\u3053\u304b\u3067\u4e00\u5143\u7ba1\u7406\u3059\u3079\u304d\u306a\u306e\u3067\u3001\u4ee5Laravel\u306e\u30e2\u30c7\u30eb\u304b\u3089\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>subjects: {\r\n    100: '\u5546\u54c1\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',\r\n    200: '\u304a\u652f\u6255\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',\r\n    300: '\u30b7\u30e7\u30c3\u30d4\u30f3\u30b0\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',\r\n    400: '\u30dd\u30a4\u30f3\u30c8\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',\r\n    500: '\u3054\u8cea\u554f\u30fb\u305d\u306e\u4ed6',\r\n},<\/pre>\n<p>\u307e\u305a\u3001\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067<code>EmailSubject<\/code>\u3068\u3044\u3046\u30e2\u30c7\u30eb\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>php artisan make:model EmailSubject<\/strong><\/pre>\n<p>\u305d\u3057\u3066\u3001\u4e2d\u8eab\u3092\u6b21\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002\uff08\u4eca\u56de\u306fDB\u3078\u683c\u7d0d\u306f\u3057\u306a\u3044\u306e\u3067<code>extends<\/code>\u90e8\u5206\u306f\u524a\u9664\u3057\u307e\u3057\u305f\uff09<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App;\r\n\r\nclass EmailSubject\r\n{\r\n<strong>    public static function all() {<\/strong>\r\n\r\n<strong>        return collect([<\/strong>\r\n<strong>            '100' =&gt; '\u5546\u54c1\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',<\/strong>\r\n<strong>            '200' =&gt; '\u304a\u652f\u6255\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',<\/strong>\r\n<strong>            '300' =&gt; '\u30b7\u30e7\u30c3\u30d4\u30f3\u30b0\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',<\/strong>\r\n<strong>            '400' =&gt; '\u30dd\u30a4\u30f3\u30c8\u306b\u95a2\u3059\u308b\u3054\u8cea\u554f',<\/strong>\r\n<strong>            '500' =&gt; '\u3054\u8cea\u554f\u30fb\u305d\u306e\u4ed6',<\/strong>\r\n<strong>        ]);<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u3053\u308c\u3067\u3001<code>\\App\\Email::all()<\/code>\u3068\u3059\u308b\u3068Laravel\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3067\u5168\u3054\u7528\u4ef6\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5148\u307b\u3069\u306e<code>input.balde.php<\/code>\u306e\u4e2d\u3067\u3053\u306e\u30e2\u30c7\u30eb\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>data: {\r\n    firstName: '',\r\n    lastName: '',\r\n    email: '',\r\n    subjectId: '',\r\n    body: '',\r\n    <strong>subjects: {!! \\App\\EmailSubject::all() !!},<\/strong>\r\n    emailSent: false,\r\n    errors: {}\r\n},<\/pre>\n<p>\u203b Laravel\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306f\u305d\u306e\u3082\u306e\u3092\u8868\u793a\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u81ea\u52d5\u7684\u306bJSON\u5316\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001<code>ContactController<\/code>\u306e<code>$subjects<\/code>\u3082\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<pre><strong>$subjects = \\App\\EmailSubject::all();<\/strong><\/pre>\n<p>\u6700\u5f8c\u306b\u3001<code>ContactRequest<\/code>\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30fb\u30eb\u30fc\u30eb\u3082\u5909\u66f4\u3059\u308c\u3070\u3054\u7528\u4ef6\u306e\u4e00\u5143\u7ba1\u7406\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<pre>'subject_id' =&gt; 'required|in:'. <strong>\\App\\EmailSubject::all()-&gt;keys()-&gt;implode(',')<\/strong>,<\/pre>\n<h1>\u4eca\u56de\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u30fb\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h1>\n<p>\u4eca\u56de\u306e\u958b\u767a\u3067\u5b9f\u969b\u306b\u4f5c\u6210\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u30fb\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3002\u305c\u3072\u5b66\u7fd2\u306b\u5f79\u7acb\u3066\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u203b \u306a\u304a\u3001<code>validation.php<\/code>\u306f\u3054\u81ea\u8eab\u3067\u30b3\u30d4\u30fc\u3057\u3066\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=1811&amp;tmstv=1777557598\" rel=\"nofollow\" id=\"download-link-1811\" data-redirect=\"false\" >\n\tLaravel + Vue \u3067\u554f\u3044\u5408\u308f\u305b\u30d5\u30a9\u30fc\u30e0\uff1a \u30d7\u30ed\u30b0\u30e9\u30e0\u30fb\u30b3\u30fc\u30c9\u4e00\u5f0f<\/a>\n\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u30a6\u30a7\u30d6\u958b\u767a\u3092\u3057\u3066\u3044\u308b\u3068\u3088\u304f\u5fc5\u8981\u306b\u306a\u308b\u6a5f\u80fd\u306e\u3072\u3068\u3064\u306b\u304a\u554f\u3044\u5408\u308f\u305b\u30d5\u30a9\u30fc\u30e0\u304c\u3042\u308a\u307e\u3059\u3002 \u3082\u3061\u308d\u3093\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3055\u3093\u3060\u3051\u304c\u5229\u7528\u3059\u308b\u30bf\u30a4\u30d7\u306e\u30b5\u30a4\u30c8\u306a\u3089\u4e0d\u8981\u3067\u3059\u304c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=1783\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel + Vue \u3067\u554f\u3044\u5408\u308f\u305b\u30d5\u30a9\u30fc\u30e0\u3092\u3064\u304f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":1800,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,12],"tags":[81],"class_list":["post-1783","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-vue-js","tag-81"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1783","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=1783"}],"version-history":[{"count":10,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1783\/revisions"}],"predecessor-version":[{"id":1814,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1783\/revisions\/1814"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/1800"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}