{"id":5022,"date":"2019-11-18T18:24:30","date_gmt":"2019-11-18T09:24:30","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=5022"},"modified":"2020-04-19T00:00:18","modified_gmt":"2020-04-18T15:00:18","slug":"%e3%80%90laravel%e3%80%91db%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92csv%e3%81%a7%e3%82%a4%e3%83%b3%e3%83%9d%e3%83%bc%e3%83%88%e3%81%99%e3%82%8b%e6%a9%9f%e8%83%bd%e3%82%92%e3%81%a4%e3%81%8f%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=5022","title":{"rendered":"\u3010Laravel\u3011DB\u30c7\u30fc\u30bf\u3092CSV\u3067\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u6a5f\u80fd\u3092\u3064\u304f\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u524d\u56de\u30fb\u524d\u3005\u56de\u3068DB\u306e\u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u306b\u95a2\u9023\u3059\u308b\u8a71\u984c\u3092\u304a\u5c4a\u3051\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u6d41\u308c\u3067\u4f55\u304b\u8a18\u4e8b\u306b\u3067\u304d\u306a\u3044\u304b\u3068\u8003\u3048\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u3072\u3068\u3064\u307e\u3060\u3053\u306e\u30d6\u30ed\u30b0\u3067\u306f\u7d39\u4ecb\u3057\u3066\u3044\u306a\u3044\u5185\u5bb9\u3092\u601d\u3044\u3064\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u306f\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">CSV\u30d5\u30a1\u30a4\u30eb\u306e\u30a4\u30f3\u30dd\u30fc\u30c8<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001<code>CSV<\/code>\u30d5\u30a1\u30a4\u30eb\u306b\u305f\u304f\u3055\u3093\u306e\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u304c\u5165\u3063\u3066\u3044\u3066\u3001\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u3067DB\u306e<code>users<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u3044\u3046\u3001\u3042\u308b\u7a2e\u30e6\u30fc\u30b6\u30fc\u30d3\u30ea\u30c6\u30a3\u306b\u3082\u901a\u3058\u308b\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u3053\u306e\u6a5f\u80fd\u3092\u5fdc\u7528\u3059\u308c\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3060\u3051\u3067\u306a\u304f\u5546\u54c1\u30c7\u30fc\u30bf\u306a\u3069\u305d\u306e\u4ed6\u306e\u30c7\u30fc\u30bf\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u306e\u304a\u5f79\u306b\u7acb\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2173 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png\" alt=\"\" width=\"300\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24-281x300.png 281w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u958b\u767a\u74b0\u5883\uff1a Laravel 6.x<\/p>\n<h1>\u524d\u63d0\u3068\u3057\u3066<\/h1>\n<p>\u4eca\u56de\u306f<code>users<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u30c7\u30fc\u30bf\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3092\u3059\u308b\u306e\u3067\u3001<code>Laravel<\/code>\u306e\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u304c\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u8a73\u3057\u304f\u306f\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li>Laravel 6.x \u4ee5\u4e0a\u3000\u30fb\u30fb\u30fb\u3000<a href=\"https:\/\/blog.capilano-fw.com\/?p=4576\">Laravel6.0\u3067\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u4f7f\u3046\u65b9\u6cd5<\/a><\/li>\n<li>\u305d\u308c\u672a\u6e80\u3000\u30fb\u30fb\u30fb\u3000<a href=\"https:\/\/blog.capilano-fw.com\/?p=289\">\u3010Laravel5.6\u3011\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u76f4\u5f8c\u306b\u3084\u308b\u3053\u3068\uff13\u70b9<\/a><\/li>\n<\/ul>\n<h1>\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p><code>CSV<\/code>\u306e\u30c7\u30fc\u30bf\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8<a href=\"https:\/\/github.com\/SUKOHI\/CsvValidator\" target=\"_blank\" rel=\"noopener noreferrer\">csv-validator<\/a>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\uff08\u79c1\u304c\u516c\u958b\u3057\u3066\u3044\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002\u4eca\u56de\u306e\u305f\u3081\u306b\u30d5\u30eb\u3067\u66f8\u304d\u76f4\u3057\u307e\u3057\u305f\ud83d\ude0a\uff09<\/p>\n<pre><strong>composer require sukohi\/csv-validator:3.*<\/strong><\/pre>\n<h1>\u30eb\u30fc\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5148\u306b\u30eb\u30fc\u30c8\u3092\u3064\u304f\u3063\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong><code>\/routes\/web.php<\/code><\/strong><\/p>\n<pre><strong>Route::get('csv_import', 'CsvImportController@create');<\/strong>\r\n<strong>Route::post('ajax\/csv_import', 'CsvImportController@ajax_store');<\/strong><\/pre>\n<p>\uff11\u884c\u76ee\u304c\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30eb\u30fc\u30c8\u3067\u3001\uff12\u884c\u76ee\u306f<code>CSV\u30d5\u30a1\u30a4\u30eb<\/code>\u3092<code>Ajax<\/code>\u3067\u9001\u4fe1\u3059\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<h1>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p>\u7d9a\u3044\u3066\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308a\u307e\u3059\u3002<br \/>\n<span style=\"font-size: 1rem;\">\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/span><\/p>\n<pre><strong>php artisan make:controller CsvImportController<\/strong><\/pre>\n<p>\u305d\u3057\u3066\u3001\u4e2d\u8eab\u3092\u6b21\u306e\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong><code>app\/Http\/Controllers\/CsvImportController.php<\/code><\/strong><\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse Illuminate\\Http\\Request;\r\nuse Sukohi\\CsvValidator\\Rules\\Csv;\r\n\r\nclass CsvImportController extends Controller\r\n{\r\n    public function create() {\r\n\r\n        return view('csv_import.create');\r\n\r\n    }\r\n\r\n    <strong>public function ajax_store(Request $request) {<\/strong>\r\n\r\n<strong>        $csv_rules = [<\/strong>\r\n<strong>            0 =&gt; 'required|email|unique:users,email',<\/strong>\r\n<strong>            1 =&gt; 'required|string',<\/strong>\r\n<strong>            2 =&gt; 'required|string|min:6'<\/strong>\r\n<strong>        ];<\/strong>\r\n<strong>        $request-&gt;validate([<\/strong>\r\n<strong>            'csv_file' =&gt; [<\/strong>\r\n<strong>                'required',<\/strong>\r\n<strong>                'file',<\/strong>\r\n<strong>                new Csv($csv_rules, 'sjis-win')<\/strong>\r\n<strong>            ]<\/strong>\r\n<strong>        ]);<\/strong>\r\n\r\n<strong>        $csv_data = $request-&gt;csv_file_data; \/\/ \u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u4f5c\u6210\u3057\u305fCSV\u30c7\u30fc\u30bf<\/strong>\r\n\r\n<strong>        foreach($csv_data as $row_data) {<\/strong>\r\n\r\n<strong>            $user = new \\App\\User();<\/strong>\r\n<strong>            $user-&gt;email = $row_data[0];<\/strong>\r\n<strong>            $user-&gt;name = $row_data[1];<\/strong>\r\n<strong>            $user-&gt;password = bcrypt($row_data[2]);<\/strong>\r\n<strong>            $user-&gt;save();<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        return ['result' =&gt; true];<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u306f\u3001<code>create()<\/code>\u304c\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3001<code>ajax_store()<\/code>\u304c<code>Ajax<\/code>\u3092\u901a\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001<code>ajax_store()<\/code>\u306e\u4e2d\u3067\u306f\u3001\u307e\u305a\u5148\u307b\u3069\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u3064\u304b\u3063\u3066\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u3001\u554f\u984c\u304c\u306a\u3051\u308c\u3070\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u305f<code>CSV<\/code>\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u30e6\u30fc\u30b6\u30fc\u3092\u65b0\u898f\u767b\u9332\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p><code>\/resources\/views\/csv_import\/create.blade.php<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u3064\u304f\u3063\u3066\u4e2d\u8eab\u3092\u6b21\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;html&gt;\r\n&lt;body&gt;\r\n    &lt;div id=\"app\"&gt;\r\n        &lt;h1&gt;CSV\u30d5\u30a1\u30a4\u30eb\u3067DB\u306b\u30a4\u30f3\u30dd\u30fc\u30c8&lt;\/h1&gt;\r\n        &lt;label&gt;CSV\u30d5\u30a1\u30a4\u30eb&lt;\/label&gt;&lt;br&gt;\r\n        &lt;input id=\"file\" type=\"file\" <strong>@change=\"onFileChange\"<\/strong>&gt;\r\n        <strong>&lt;div v-if=\"csvErrors\"&gt;\r\n            &lt;ul&gt;\r\n                &lt;li v-for=\"error in csvErrors\" v-text=\"error\"&gt;&lt;\/li&gt;\r\n            &lt;\/ul&gt;\r\n        &lt;\/div&gt;<\/strong>\r\n        &lt;br&gt;\r\n        &lt;button type=\"button\" <strong>@click=\"onSubmit\"<\/strong>&gt;\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b&lt;\/button&gt;\r\n    &lt;\/div&gt;\r\n    &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue@2.6.0\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/axios\/0.19.0\/axios.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script&gt;\r\n\r\n        new Vue({\r\n            el: '#app',\r\n            data: {\r\n                csvFile: null,\r\n                csvErrors: []\r\n            },\r\n            methods: {\r\n                <strong>onFileChange(e) {\r\n\r\n                    this.csvFile = e.target.files[0];\r\n\r\n                },<\/strong>\r\n                <strong>onSubmit() {<\/strong>\r\n\r\n<strong>                    this.csvErrors = [];<\/strong>\r\n\r\n<strong>                    const url = '\/ajax\/csv_import';<\/strong>\r\n<strong>                    let formData = new FormData();<\/strong>\r\n<strong>                    formData.append('csv_file', this.csvFile);<\/strong>\r\n<strong>                    axios.post(url, formData)<\/strong>\r\n<strong>                        .then(response =&gt; {<\/strong>\r\n\r\n<strong>                            if(response.data.result) {<\/strong>\r\n\r\n<strong>                                document.getElementById('file').value = '';<\/strong>\r\n<strong>                                alert('\u30a4\u30f3\u30dd\u30fc\u30c8\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002');<\/strong>\r\n\r\n<strong>                            }<\/strong>\r\n\r\n<strong>                        })<\/strong>\r\n<strong>                        .catch(error =&gt; {<\/strong>\r\n\r\n<strong>                            this.csvErrors = error.response.data.errors.csv_file;<\/strong>\r\n\r\n<strong>                        });<\/strong>\r\n\r\n<strong>                }<\/strong>\r\n            }\r\n        });\r\n\r\n    &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u91cd\u8981\u306a\u306e\u306f\uff12\u30f6\u6240\u3067\u3059\u3002<\/p>\n<p>\u307e\u305a\u3072\u3068\u3064\u3081\u306f\u3001<code>&lt;input type=\"file\"&gt;<\/code>\u306b\u3064\u3051\u3089\u308c\u305f<code>change<\/code>\u30a4\u30d9\u30f3\u30c8\u3067\u3059\u3002\u3053\u306e\u30a4\u30d9\u30f3\u30c8\u304c\u5b9f\u884c\u3055\u308c\u308b\u3068\u3001<code>onFileChange<\/code>\u304c\u547c\u3070\u308c\u3001\u9078\u629e\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u60c5\u5831\u304c<code>Vue<\/code>\u306e<code>data<\/code>\u306b\u4fdd\u6301\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3082\u3046\u3072\u3068\u3064\u306f<strong>\u300c\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u300d<\/strong>\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308b<code>onSubmit()<\/code>\u306e\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f\u3001\u9078\u629e\u3055\u308c\u305f<code>csv<\/code>\u30d5\u30a1\u30a4\u30eb\u3092<code>FormData<\/code>\u3067\u9001\u4fe1\u3057\u3066\u3044\u307e\u3059\u3002\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306e\u306f\u5148\u307b\u3069\u3064\u304f\u3063\u305f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e<code>ajax_store()<\/code>\u3067\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u3082\u3057\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306f<code>&lt;input type=\"file\"&gt;<\/code>\u306e\u4e0b\u306b<code>v-for<\/code>\u3092\u4f7f\u3063\u3066\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5025\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_1.png\" alt=\"\" width=\"477\" height=\"201\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_1.png 477w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_1-300x126.png 300w\" sizes=\"auto, (max-width: 477px) 100vw, 477px\" \/><\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u4ee5\u4e0b\u306e<code>CSV<\/code>\u3092\u9001\u4fe1\u3057\u3066\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\n\u6587\u5b57\u30b3\u30fc\u30c9\u306f<code>Shift_JIS<\/code>\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5028\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_2.png\" alt=\"\" width=\"316\" height=\"115\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_2.png 316w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_2-300x109.png 300w\" sizes=\"auto, (max-width: 316px) 100vw, 316px\" \/><\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3057\u3066\u9001\u4fe1\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5030\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_3.png\" alt=\"\" width=\"488\" height=\"208\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_3.png 488w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_3-300x128.png 300w\" sizes=\"auto, (max-width: 488px) 100vw, 488px\" \/><\/p>\n<p>\u5b9f\u884c\u5f8c\u306e<code>users<\/code>\u30c6\u30fc\u30d6\u30eb\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5031\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_4.png\" alt=\"\" width=\"728\" height=\"391\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_4.png 728w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_4-300x161.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<p>\u3046\u307e\u304f\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\ud83d\ude0a<\/p>\n<p>\u3067\u306f\u6b21\u306b\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u3046\u307e\u304f\u50cd\u3044\u3066\u3044\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u305f\u3081\u306b\u3001\u4eca\u306e\u72b6\u614b\u306e\u307e\u307e\u3067\u6b21\u306e<code>CSV<\/code>\u30d5\u30a1\u30a4\u30eb\u3092\u9001\u4fe1\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5032\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_5.png\" alt=\"\" width=\"317\" height=\"80\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_5.png 317w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_5-300x76.png 300w\" sizes=\"auto, (max-width: 317px) 100vw, 317px\" \/><\/p>\n<p>\u9001\u4fe1\u3059\u308b\u3068\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5033\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_6.png\" alt=\"\" width=\"484\" height=\"345\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_6.png 484w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/11\/csv_import_6-300x214.png 300w\" sizes=\"auto, (max-width: 484px) 100vw, 484px\" \/><\/p>\n<p>\u6210\u529f\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<h1>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b \u305f\u3060\u3057\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u3054\u81ea\u8eab\u3067\u884c\u3063\u3066\u304f\u3060\u3055\u3044\u3002\u307e\u305f\u3001<code>storage\/app\/csv<\/code>\u306b\u306f\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u7528\u306e<code>user.csv<\/code>\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=5036&amp;tmstv=1777536623\" rel=\"nofollow\" id=\"download-link-5036\" data-redirect=\"false\" >\n\tDB\u30c7\u30fc\u30bf\u3092CSV\u3067\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u6a5f\u80fd\u3092\u3064\u304f\u308b<\/a>\n\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>CSV<\/code>\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3063\u305f\u30a4\u30f3\u30dd\u30fc\u30c8\u6a5f\u80fd\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u6bd4\u8f03\u7684\u306b\u30c7\u30fc\u30bf\u3092<code>CSV<\/code>\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\u6a5f\u80fd\u306f\u7c21\u5358\u306a\u306e\u3067\u3059\u304c\u3001\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306e\u5834\u5408\u306f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u304f\u308b\u306e\u3067\u3061\u3087\u3063\u3068\u624b\u9593\u3060\u3063\u305f\u308a\u3057\u307e\u3059\u304c\u3001\u4eca\u56de\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u3063\u3066\u3044\u305f\u3060\u304f\u3068\u6642\u77ed\u3067\u958b\u767a\u304c\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u4eca\u56de\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u5185\u90e8\u7684\u306b\u306f\u540c\u3058\u304f\u79c1\u304c\u516c\u958b\u3057\u3066\u3044\u308b<a href=\"https:\/\/github.com\/SUKOHI\/FluentCsv\" target=\"_blank\" rel=\"noopener noreferrer\">fluent-csv<\/a>\u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306f\u5143\u3005<code>php-spreadsheet<\/code>\u3067<code>Shift_JIS<\/code>\u306e<code>CSV<\/code>\u304c\u4f5c\u308c\u306a\u304b\u3063\u305f\u306e\u3067\u4f5c\u6210\u3057\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u304c\u3001\u73fe\u5728\u306fCSV\u306e\u300c\u8aad\u307f\u30fb\u66f8\u304d\u300d\u4e21\u65b9\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u306e\u3067\u3053\u3061\u3089\u3082\u8208\u5473\u304c\u3042\u308b\u304b\u305f\u306f\u305c\u3072\u4f7f\u3063\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-25 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2017\/06\/15.png\" alt=\"\" width=\"348\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2017\/06\/15.png 348w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2017\/06\/15-300x276.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2017\/06\/15-30x28.png 30w\" sizes=\"auto, (max-width: 348px) 100vw, 348px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u524d\u56de\u30fb\u524d\u3005\u56de\u3068DB\u306e\u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u306b\u95a2\u9023\u3059\u308b\u8a71\u984c\u3092\u304a\u5c4a\u3051\u3057\u307e\u3057\u305f\u3002 \u305d\u3057\u3066\u3001\u3053\u306e\u6d41\u308c\u3067\u4f55\u304b\u8a18\u4e8b\u306b\u3067\u304d\u306a\u3044\u304b\u3068\u8003\u3048\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u3072\u3068\u3064\u307e\u3060\u3053\u306e\u30d6\u30ed\u30b0\u3067 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=5022\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u3010Laravel\u3011DB\u30c7\u30fc\u30bf\u3092CSV\u3067\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u6a5f\u80fd\u3092\u3064\u304f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":5042,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,97],"tags":[9],"class_list":["post-5022","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-97","tag-csv"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/5022","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=5022"}],"version-history":[{"count":10,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/5022\/revisions"}],"predecessor-version":[{"id":7101,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/5022\/revisions\/7101"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/5042"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}