{"id":7481,"date":"2020-06-29T15:00:58","date_gmt":"2020-06-29T06:00:58","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=7481"},"modified":"2020-06-20T04:42:14","modified_gmt":"2020-06-19T19:42:14","slug":"laravel%e3%81%a7%e3%83%a6%e3%83%bc%e3%82%b6%e3%83%bc%e7%ae%a1%e7%90%86%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=7481","title":{"rendered":"Laravel\u3067\u30e6\u30fc\u30b6\u30fc\u7ba1\u7406\u6a5f\u80fd\u3092\u3064\u304f\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u904e\u53bb\u306b<code>Laravel<\/code>\u3067\u3044\u308d\u3044\u308d\u306a\u30b7\u30b9\u30c6\u30e0\u3092\u958b\u767a\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u304c\u3001\u4e2d\u3067\u3082\u30ed\u30b0\u30a4\u30f3\u304c\u5fc5\u8981\u306a\u30b5\u30a4\u30c8\u3067\u3088\u304f\u3054\u4f9d\u983c\u3092\u3044\u305f\u3060\u304f\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u306f\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u30e6\u30fc\u30b6\u30fc\u7ba1\u7406\u6a5f\u80fd<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u300c<strong>\u30e6\u30fc\u30b6\u30fc\u7ba1\u7406\u6a5f\u80fd<\/strong>\u300d\u3068\u306f\u305d\u306e\u540d\u306e\u3068\u304a\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u3092\uff08\u8ffd\u52a0\u30fb\u5909\u66f4\u30fb\u524a\u9664\uff09\u3059\u308b\u6a5f\u80fd\u306e\u3053\u3068\u3067\u3001\u7ba1\u7406\u8005\u3055\u3093\u306e\u305f\u3081\u306b\u958b\u767a\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u30b5\u30a4\u30c8\u306b\u3088\u3063\u3066\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d7\u30e9\u30b9\u30a2\u30eb\u30d5\u30a1\u304c\u5fc5\u8981\u306b\u306a\u308b\u5834\u5408\u3082\u3042\u308a\u307e\u3059\u304c\u6700\u4f4e\u3067\u3082\u4e0a\u306e\uff13\u3064\u306e\u6a5f\u80fd\u304c\u3042\u308c\u3070\u30e6\u30fc\u30b6\u30fc\u7ba1\u7406\u306f\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p><strong>\u30d7\u30e9\u30b9\u30a2\u30eb\u30d5\u30a1\u306e\u4f8b\uff1a<\/strong><\/p>\n<ul>\n<li>\u30a2\u30a4\u30b3\u30f3\u753b\u50cf\u306e\u8ffd\u52a0\u30fb\u5909\u66f4\u30fb\u524a\u9664<\/li>\n<li>CSV\u3067\u306e\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\uff0f\u30a4\u30f3\u30dd\u30fc\u30c8\u6a5f\u80fd<\/li>\n<li>\u7279\u5b9a\u306e\u30e6\u30fc\u30b6\u30fc\u3068\u3057\u3066\u81ea\u52d5\u30ed\u30b0\u30a4\u30f3<\/li>\n<\/ul>\n<p>\u305d\u3053\u3067\u2757<\/p>\n<p>\u4eca\u56de\u306f<code>Laravel<\/code>\u3067\u30e6\u30fc\u30b6\u30fc\u7ba1\u7406\u6a5f\u80fd\u3092\u3064\u304f\u308b\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u3053\u3053\u306e\u3068\u3053\u308d\u5c11\u3057\u8907\u96d1\u306a\u8a18\u4e8b\u304c\u591a\u304f\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u3001\u4eca\u56de\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u300c\u8d85\u30df\u30cb\u30de\u30eb\u300d\u306a\u69cb\u6210\u3067\u304a\u5c4a\u3051\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u3067\u304d\u308b\u3060\u3051\u5c11\u306a\u3044\u30d5\u30a1\u30a4\u30eb<\/li>\n<li>\u3067\u304d\u308b\u3060\u3051\u5c11\u306a\u3044\u30e1\u30bd\u30c3\u30c9<\/li>\n<li>\u3067\u304d\u308b\u3060\u3051\u5c11\u306a\u3044\u30b3\u30fc\u30c9\uff08\u3067\u3082\u898b\u3084\u3059\u3055\u512a\u5148\u2757\uff09<\/li>\n<\/ul>\n<p>\u305c\u3072\u7686\u3055\u3093\u306e\u304a\u5f79\u306b\u7acb\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\ud83d\ude0a\u2728<br \/>\n\uff08\u8a18\u4e8b\u306e\u6700\u5f8c\u3067\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3088\ud83d\udc4d\uff09<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6066 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23.png\" alt=\"\" width=\"370\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23-300x259.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/>\u300c\u306a\u305c\u304b\u30b3\u30f3\u30bf\u30af\u30c8\u304c\u53f3\u3060\u3051\u591a\u304f\u6b8b\u308b\u3093\u3067\u3059\u304c\u3001<br \/>\n\u4e0d\u601d\u8b70\u3067\u3057\u3087\u3046\u304c\u306a\u3044\u3067\u3059\ud83d\ude2b\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 7.x<\/p>\n<h1>\u524d\u63d0\u3068\u3057\u3066<\/h1>\n<p>\u4eca\u56de\u3082<code>Laravel<\/code>\u306b\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc\u3092\u8ffd\u52a0\u3057\u3066\u304b\u3089\u8a66\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3082\u3057\u307e\u3060\u306e\u65b9\u306f\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"https:\/\/blog.capilano-fw.com\/?p=4576\">Laravel6.x\u4ee5\u964d\u3067\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u65b9\u6cd5<\/a><\/p>\n<p>\u306a\u304a\u3001\u4eca\u56de\u306e\u8a18\u4e8b\u3067\u306f\u30e6\u30fc\u30b6\u30fc\u306e\uff08\u8ffd\u52a0\u30fb\u5909\u66f4\u30fb\u524a\u9664\uff09\u3060\u3051\u3092\u53d6\u308a\u6271\u3044\u307e\u3059\u304c\u3001\u7ba1\u7406\u8005\u3060\u3051\u3053\u306e\u6a5f\u80fd\u3092\u6709\u52b9\u306b\u3059\u308b\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3067\u300crole\uff08\u5f79\u5272\u2252\u6a29\u9650\uff09\u300d\u3082\u7528\u610f\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"https:\/\/blog.capilano-fw.com\/?p=420\">\u30b7\u30f3\u30d7\u30eb\uff01Laravel5.6\u3067\u300c\u6a29\u9650\u3064\u304d\u300d\u30ed\u30b0\u30a4\u30f3\u3055\u305b\u308b\u65b9\u6cd5<\/a><\/p>\n<p>\u3067\u306f\u3084\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u2757<\/p>\n<h1>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p>\u307e\u305a\u306f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308a\u307e\u3059\u304c\u3001\u4eca\u56de\u306f\u300c\u30df\u30cb\u30de\u30eb\u300d\u306a\u4ed5\u69d8\u306a\u306e\u3067\u3044\u3064\u3082\u3068\u306f\u9055\u3063\u305f\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>php artisan make:controller UserController --resource --model=User<\/strong><\/pre>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u610f\u5473\u306b\u3064\u3044\u3066\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>&#8211;resource\uff1a \uff08\u8ffd\u52a0\u30fb\u5909\u66f4\u30fb\u524a\u9664\u30fb\u8868\u793a\uff09\u306b\u5bfe\u5fdc\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u304f\u308c\u307e\u3059\u3002\u4f8b\uff1aindex(), create(), update()\u306a\u3069<\/li>\n<li>&#8211;model\uff1a \u4e0a\u3067\u8ffd\u52a0\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u306b\u3055\u3089\u306b\u30e2\u30c7\u30eb\u3092\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u30b3\u30fc\u30c9\u3082\u8ffd\u52a0\u3057\u3066\u304f\u308c\u307e\u3059\u3002\u4f8b\uff1a<code>function show(<strong>User $user<\/strong>) { ... }<\/code><\/li>\n<\/ul>\n<p>\u3064\u307e\u308a\u3001<strong>\u3069\u3046\u305b\u66f8\u304f\u3053\u3068\u306b\u306a\u308b\u30b3\u30fc\u30c9\u3092\u7701\u7565\u3067\u304d\u308b\u30b3\u30de\u30f3\u30c9\u3060\u3068\u8003\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/strong><\/p>\n<p>\u3067\u306f\u3001\u4f5c\u6210\u3057\u305f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u4e2d\u8eab\u3092\u6b21\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><code>\/app\/Http\/Controllers\/UserController.php<\/code><\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse App\\User;\r\nuse Illuminate\\Http\\Request;\r\n\r\nclass UserController extends Controller\r\n{\r\n    <strong>public function index()\r\n    {\r\n        $per_page = 3; \/\/ \uff11\u30da\u30fc\u30b8\u3054\u3068\u306e\u8868\u793a\u4ef6\u6570\r\n        $users = \\App\\User::paginate($per_page);\r\n        return view('user.index')-&gt;with('users', $users);\r\n    }\r\n\r\n    public function store(Request $request)\r\n    {\r\n        \/\/ [\u3054\u6ce8\u610f]\uff1a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u7701\u7565\u3057\u3066\u307e\u3059\r\n\r\n        $user = new \\App\\User();\r\n        $user-&gt;name = $request-&gt;name;\r\n        $user-&gt;email = $request-&gt;email;\r\n        $user-&gt;password = bcrypt($request-&gt;password);\r\n        $result = $user-&gt;save();\r\n        return ['result' =&gt; $result];\r\n    }\r\n\r\n    public function update(Request $request, User $user)\r\n    {\r\n        \/\/ [\u3054\u6ce8\u610f]\uff1a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u7701\u7565\u3057\u3066\u307e\u3059\r\n\r\n        $user-&gt;name = $request-&gt;name;\r\n        $user-&gt;email = $request-&gt;email;\r\n\r\n        if($request-&gt;filled('password')) { \/\/ \u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u304c\u3042\u308b\u3068\u304d\u3060\u3051\u5909\u66f4\r\n\r\n            $user-&gt;password = bcrypt($request-&gt;password);\r\n\r\n        }\r\n\r\n        $result = $user-&gt;save();\r\n        return ['result' =&gt; $result];\r\n    }\r\n\r\n    public function destroy(User $user)\r\n    {\r\n        $result = $user-&gt;delete();\r\n        return ['result' =&gt; $result];\r\n    }<\/strong>\r\n}<\/pre>\n<p>\u3067\u306f\u3001\u30b3\u30fc\u30c9\u304c\u5c11\u3057\u9577\u3044\u306e\u3067\u30e1\u30bd\u30c3\u30c9\u3054\u3068\u306b\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p><strong>index()<\/strong><\/p>\n<p>\u4eca\u56de\u306f<code>index()<\/code>\u3060\u3051\u304c\u76f4\u63a5\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3001\u4ed6\u306f\u5168\u3066<code>Ajax\u9001\u4fe1<\/code>\u306e\u305f\u3081\u306b\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u4e2d\u3067\u306f\u3001\uff11\u30da\u30fc\u30b8\u3054\u3068\u306b\u8868\u793a\u3059\u308b\u30e6\u30fc\u30b6\u30fc\u30fb\u30c7\u30fc\u30bf\u3092<code>paginate()<\/code>\u3067\u53d6\u5f97\u3057\u3001\u30d3\u30e5\u30fc\u306b\u9001\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>store()<\/strong><\/p>\n<p>\u65b0\u898f\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<br \/>\nAjax\u306e\u300c<strong>POST<\/strong>\u300d\u3067\u9001\u4fe1\u3055\u308c\u308b\u3053\u3068\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001<code>bcrypt()<\/code>\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6697\u53f7\u5316\u3059\u308b\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u3067\u3059\u3002<br \/>\n\u3053\u308c\u3092\u5fd8\u308c\u308b\u3068\u3069\u3093\u306a\u306b\u9811\u5f35\u3063\u3066\u3082\u30ed\u30b0\u30a4\u30f3\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u5fd8\u308c\u305a\u3064\u3051\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>update()<\/strong><\/p>\n<p>\u3059\u3067\u306b\u5b58\u5728\u3059\u308b\u30e6\u30fc\u30b6\u30fc\u306e\u30c7\u30fc\u30bf\u3092\u5909\u66f4\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3001\u300c<strong>PUT<\/strong>\u300d\u3067\u9001\u4fe1\u3055\u308c\u308b\u3053\u3068\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u9014\u4e2d<code>if\u6587<\/code>\u3092\u3064\u304f\u3063\u3066\u3044\u308b\u306e\u306f\u3001<strong>\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u5165\u529b\u304c\u3042\u308b\u3068\u304d\u3060\u3051\u4fdd\u5b58\u3059\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u304b\u3089\u3067\u3059\u3002<\/strong><\/p>\n<p>\u306a\u304a\u3001\u4eca\u56de\u306f\u30c6\u30b9\u30c8\u3067\u3059\u306e\u3067<code>store()<\/code>\u3068<code>update()<\/code>\u306b\u306f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u3064\u3051\u3066\u3044\u307e\u305b\u3093\u306e\u3067\u304a\u6c17\u3092\u3064\u3051\u304f\u3060\u3055\u3044\u3002m_ _m<\/p>\n<p><strong>destroy()<\/strong><\/p>\n<p>\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<br \/>\n\u3053\u3061\u3089\u306f\u300c<strong>DELETE<\/strong>\u300d\u30e1\u30bd\u30c3\u30c9\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u30eb\u30fc\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u30eb\u30fc\u30c8\u3082\u30df\u30cb\u30de\u30eb\u4ed5\u69d8\u3067\u66f8\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><code>\/routes\/web.php<\/code><\/p>\n<pre><strong>Route::resource('user', 'UserController')-&gt;only(['index', 'store', 'update', 'destroy']);<\/strong><\/pre>\n<p>\u300c\u304a\u3084\u3001\u3055\u3063\u304d\u30e1\u30bd\u30c3\u30c9\u306f\uff14\u3064\u3042\u3063\u305f\u3051\u3069\u2753\u2753\u300d\u3068\u601d\u3063\u305f\u65b9\u3082\u3044\u3089\u3063\u3057\u3083\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c<span style=\"font-size: 1rem;\">\u3001\u3053\u306e\uff11\u884c\u3060\u3051\u3067OK\u3067\u3059\u3002<\/span><\/p>\n<p>\u306a\u305c\u306a\u3089\u3001<code>Route::resource()<\/code>\u306f\u3001\u3010\u8ffd\u52a0\u30fb\u5909\u66f4\u30fb\u524a\u9664\u30fb\u8868\u793a\u3011\u306b\u5fc5\u8981\u306a\u4ee5\u4e0b\u306e\u30e1\u30bd\u30c3\u30c9\u5168\u3066\u3092\uff11\u884c\u3067\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u308b\u6a5f\u80fd\u3060\u304b\u3089\u3067\u3059\u3002<\/p>\n<ul>\n<li>index()\uff1a \u4e00\u89a7\u8868\u793a<\/li>\n<li>create()\uff1a\u8ffd\u52a0\uff08\u30d5\u30a9\u30fc\u30e0\uff09<\/li>\n<li>store()\uff1a \u8ffd\u52a0\uff08\u9001\u4fe1\u5148\uff09<\/li>\n<li>show()\uff1a \uff11\u4ef6\u8868\u793a<\/li>\n<li>edit()\uff1a \u5909\u66f4\uff08\u30d5\u30a9\u30fc\u30e0\uff09<\/li>\n<li>update()\uff1a \u5909\u66f4\uff08\u9001\u4fe1\u5148\uff09<\/li>\n<li>destory()\uff1a \u524a\u9664<\/li>\n<\/ul>\n<p>\u203b\u3064\u307e\u308a\u3001<code>create()<\/code>\uff06<code>store()<\/code>\u3001\u305d\u3057\u3066<code>edit()<\/code>\uff06<code>update()<\/code>\u306f\u30da\u30a2\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001<code>Route::resource()<\/code>\u306b<code>only()<\/code>\u3067\u5fc5\u8981\u306a\u30e1\u30bd\u30c3\u30c9\u3060\u3051\u3092\u6709\u52b9\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n<h1>\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p>\u7e70\u308a\u8fd4\u3057\u3067\u3059\u304c\u3001\u30d3\u30e5\u30fc\u3082\u300c\u30df\u30cb\u30de\u30eb\u300d\u3067\u3044\u304d\u307e\u3059\u2757\uff08\uff11\u30d5\u30a1\u30a4\u30eb\u3060\u3051\u3067\u5b9f\u88c5\u3057\u307e\u3059\uff09<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><code>\/resources\/views\/user\/index.blade.php<\/code><\/p>\n<pre>&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;link href=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.5.0\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;div id=\"app\" class=\"p-5\"&gt;\r\n        <strong>&lt;!-- \u4e00\u89a7\u8868\u793a\u3059\u308b\u30d6\u30ed\u30c3\u30af \u2460 --&gt;<\/strong>\r\n        &lt;div v-if=\"state=='index'\"&gt;\r\n            &lt;div class=\"mb-3\"&gt;\r\n                &lt;button type=\"button\" class=\"btn btn-success\" @click=\"changeState('create')\"&gt;\u8ffd\u52a0&lt;\/button&gt;\r\n            &lt;\/div&gt;\r\n            &lt;table class=\"table table-striped\"&gt;\r\n                &lt;thead&gt;\r\n                    &lt;tr&gt;\r\n                        &lt;th&gt;\u540d\u524d&lt;\/th&gt;\r\n                        &lt;th&gt;E-Mail&lt;\/th&gt;\r\n                        &lt;th&gt;&lt;\/th&gt;\r\n                    &lt;\/tr&gt;\r\n                &lt;\/thead&gt;\r\n                &lt;tbody&gt;\r\n                    &lt;tr v-for=\"user in users\"&gt;\r\n                        &lt;td v-text=\"user.name\"&gt;&lt;\/td&gt;\r\n                        &lt;td v-text=\"user.email\"&gt;&lt;\/td&gt;\r\n                        &lt;td class=\"text-right\"&gt;\r\n                            &lt;button class=\"btn btn-warning\" type=\"button\" @click=\"changeState('edit', user)\"&gt;\u5909\u66f4&lt;\/button&gt;\r\n                            &lt;button class=\"btn btn-danger\" type=\"button\" @click=\"onDelete(user)\"&gt;\u524a\u9664&lt;\/button&gt;\r\n                        &lt;\/td&gt;\r\n                    &lt;\/tr&gt;\r\n                &lt;\/tbody&gt;\r\n            &lt;\/table&gt;\r\n            <strong>&lt;!-- \u30da\u30fc\u30b8\u79fb\u52d5\u306e\u30ea\u30f3\u30af \u2462 --&gt;\r\n            {{ $users-&gt;links() }}<\/strong>\r\n        &lt;\/div&gt;\r\n        <strong>&lt;!-- \u8ffd\u52a0\uff06\u5909\u66f4\u3059\u308b\u30d6\u30ed\u30c3\u30af \u2461 --&gt;<\/strong>\r\n        &lt;div v-if=\"state=='create' || state == 'edit'\"&gt;\r\n            &lt;div class=\"form-group\"&gt;\r\n                &lt;label&gt;\u540d\u524d&lt;\/label&gt;\r\n                &lt;input type=\"text\" class=\"form-control\" v-model=\"params.name\"&gt;\r\n            &lt;\/div&gt;\r\n            &lt;div class=\"form-group\"&gt;\r\n                &lt;label&gt;\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9&lt;\/label&gt;\r\n                &lt;input type=\"text\" class=\"form-control\" v-model=\"params.email\"&gt;\r\n            &lt;\/div&gt;\r\n            &lt;div class=\"bg-light px-3 py-2 mb-3\" v-if=\"state == 'edit'\"&gt;\u4ee5\u4e0b\u306f\u7701\u7565\u53ef&lt;\/div&gt;\r\n            &lt;div class=\"form-group\"&gt;\r\n                &lt;label&gt;\u30d1\u30b9\u30ef\u30fc\u30c9&lt;\/label&gt;\r\n                &lt;input type=\"password\" class=\"form-control\" v-model=\"params.password\"&gt;\r\n            &lt;\/div&gt;\r\n            &lt;div class=\"form-group\"&gt;\r\n                &lt;label&gt;\u30d1\u30b9\u30ef\u30fc\u30c9\uff08\u78ba\u8a8d\uff09&lt;\/label&gt;\r\n                &lt;input type=\"password\" class=\"form-control\" v-model=\"params.passwordConfirmation\"&gt;\r\n            &lt;\/div&gt;\r\n            &lt;button type=\"button\" class=\"btn btn-link\" @click=\"changeState('index')\"&gt;\u623b\u308b&lt;\/button&gt;\r\n            &lt;button type=\"button\" class=\"btn btn-primary\" @click=\"onSave\"&gt;\u4fdd\u5b58\u3059\u308b&lt;\/button&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue@2.6.11\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/axios\/0.19.2\/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                state: 'index',\r\n                params: {\r\n                    id: -1,\r\n                    name: '',\r\n                    email: '',\r\n                    password: '',\r\n                    passwordConfirmation: ''\r\n                },\r\n                <strong>users: [\r\n                    \/\/ \u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u3092JSON\u5316 \u2463\r\n                    @foreach($users as $user)\r\n                    {!! $user !!},\r\n                    @endforeach\r\n                ]<\/strong>\r\n            },\r\n            methods: {\r\n                <strong>changeState(state, value) { \/\/ \u72b6\u614b\u3092\u5909\u5316\u3055\u305b\u3066\u8868\u793a\u3092\u5207\u308a\u66ff\u3048 \u2464\r\n\r\n                    if(state === 'create') {\r\n\r\n                        this.params = {\r\n                            id: -1,\r\n                            name: '',\r\n                            email: '',\r\n                            password: '',\r\n                            passwordConfirmation: ''\r\n                        };\r\n\r\n                    } else if(state === 'edit') {\r\n\r\n                        this.params = value;\r\n\r\n                    }\r\n\r\n                    this.state = state;\r\n\r\n                },\r\n                onSave() { \/\/ \u30c7\u30fc\u30bf\u4fdd\u5b58\uff08\u8ffd\u52a0\uff06\u5909\u66f4\uff09 \u2465\r\n\r\n                    const params = this.params;\r\n                    let url = '\/user';\r\n                    let method = 'POST';\r\n\r\n                    if(this.state === 'edit') { \/\/ \u5909\u66f4\u306e\u5834\u5408\r\n\r\n                        url += '\/'+ this.params.id;\r\n                        method = 'PUT';\r\n\r\n                    }\r\n\r\n                    axios({ url, method, params })\r\n                        .then(response =&gt; {\r\n\r\n                            if(response.data.result === true) {\r\n\r\n                                location.reload(); \/\/ \u518d\u8aad\u307f\u8fbc\u307f\r\n\r\n                            }\r\n\r\n                        });\r\n\r\n                },\r\n                onDelete(user) { \/\/ \u30c7\u30fc\u30bf\u524a\u9664 \u2466\r\n\r\n                    if(confirm('\u524a\u9664\u3057\u307e\u3059\u3002\u3088\u308d\u3057\u3044\u3067\u3059\u304b\uff1f')) {\r\n\r\n                        const url = '\/user\/'+ user.id;\r\n                        axios.delete(url)\r\n                            .then(response =&gt; {\r\n\r\n                                if(response.data.result === true) {\r\n\r\n                                    location.reload(); \/\/ \u518d\u8aad\u307f\u8fbc\u307f\r\n\r\n                                }\r\n\r\n                            });\r\n\r\n                    }\r\n\r\n                }<\/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\u3053\u304c\u4eca\u56de\u4e00\u756a\u8907\u96d1\u306a\u90e8\u5206\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u3001\u90e8\u5206\u3054\u3068\u306b\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>\u4e00\u89a7\u8868\u793a\u3059\u308b\u30d6\u30ed\u30c3\u30af \u30fb\u30fb\u30fb\u00a0 \u2460<\/h2>\n<p>\u307e\u305a\u306f\u3058\u3081\u306b\u3001\u4eca\u56de\u306f<code>Vue<\/code>\u3092\u4f7f\u3063\u3066\u4ee5\u4e0b<strong>\uff13\u3064\u306e\u72b6\u614b\u306b\u3088\u3063\u3066\u8868\u793a\u304c\u5207\u308a\u66ff\u308f\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\uff08<\/strong>\u3053\u306e\u72b6\u614b\u3092\u4fdd\u6301\u3059\u308b\u5909\u6570\u304c<code>state<\/code>\u3067\u3059\uff09<\/p>\n<ul>\n<li>index\uff1a \u4e00\u89a7\u8868\u793a<\/li>\n<li>create\uff1a \u8ffd\u52a0\uff08\u767b\u9332\u30d5\u30a9\u30fc\u30e0\uff09<\/li>\n<li>edit\uff1a \u5909\u66f4\uff08\u5909\u66f4\u30d5\u30a9\u30fc\u30e0\uff09<\/li>\n<\/ul>\n<p>\u305d\u3057\u3066\u3001\u300c\u4e00\u89a7\u8868\u793a\u3059\u308b\u30d6\u30ed\u30c3\u30af\u300d\u306f<code>state<\/code>\u304c<code>index<\/code>\u306e\u3068\u304d\u8868\u793a\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u3001<code>&lt;table&gt; ... &lt;\/table&gt;<\/code>\u30bf\u30b0\u3067\u306f\u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u306e\u4e00\u89a7\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u8ffd\u52a0\uff06\u5909\u66f4\u3059\u308b\u30d6\u30ed\u30c3\u30af \u30fb\u30fb\u30fb \u2461<\/h2>\n<p>\u3053\u3053\u306f\u5165\u529b\u30d5\u30a9\u30fc\u30e0\u304c\u3042\u3063\u3066<code>state<\/code>\u304c<code>create<\/code>\u304b<code>edit<\/code>\u306e\u3068\u304d\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001<strong>\u30c7\u30fc\u30bf\u306e\u767b\u9332\u3068\u5909\u66f4\u306f\u3001\u5168\u304f\u540c\u3058\u30d5\u30a9\u30fc\u30e0\u3092\u4f7f\u3063\u3066\u304c\u5b9f\u884c\u3055\u308c\u308b\u3053\u3068\u306b\u6ce8\u76ee\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/strong>\u305d\u3057\u3066\u3001<code>v-model<\/code>\u3092\u4f7f\u3063\u3066\u30d5\u30a9\u30fc\u30e0\u306e\u5185\u5bb9\u3092\u5909\u5316\u3055\u305b\u307e\u3059\u3002<\/p>\n<h2>\u30da\u30fc\u30b8\u79fb\u52d5\u306e\u30ea\u30f3\u30af \u30fb\u30fb\u30fb \u2462<\/h2>\n<p>\u30da\u30fc\u30b8\u79fb\u52d5\u30ea\u30f3\u30af\u306f\u3001<code>Laravel<\/code>\u304c\u63d0\u4f9b\u3059\u308b\u3082\u306e\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u4eca\u56de\u306f\u300c\u30df\u30cb\u30de\u30eb\u4ed5\u69d8\u300d\u3068\u3044\u3046\u3053\u3068\u3067\u30da\u30fc\u30b8\u79fb\u52d5\u30ea\u30f3\u30af\u306f<code>Vue<\/code>\u3067\u8868\u793a\u3059\u308b\u306e\u306f\u3084\u3081\u306b\u3057\u307e\u3057\u305f\u3002\uff08\u3061\u3087\u3063\u3068\u8907\u96d1\u306b\u306a\u308a\u3001\u30df\u30cb\u30de\u30eb\u3067\u306f\u306a\u304f\u306a\u308b\u306e\u3067\u30fb\u30fb\u30fb\ud83d\ude02\uff09<\/p>\n<h2>\u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u3092JSON\u5316 \u30fb\u30fb\u30fb \u2463<\/h2>\n<p>\u3053\u3053\u304c<code>Laravel\uff08PHP\uff09<\/code>\u3068<code>Vue\uff08JavaScript\uff09<\/code>\u304c\u9023\u52d5\u3057\u3066\u3044\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u307e\u305a<code>$users<\/code>\u306f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u304b\u3089\u9001\u3089\u308c\u305fDB\u306e\u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u3067\u3001<strong>\u3053\u308c\u3092\u30eb\u30fc\u30d7\u3059\u308b\u3053\u3068\u3067\u52d5\u7684\u306b JavaScript \u306e\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<\/strong><\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u304c\u4f5c\u6210\u3055\u308c\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u914d\u5217\uff08\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\uff09\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\/\/ \ud83d\udc47 PHP\u3067JavaScript\u3092\u66f8\u304d\u51fa\u3059\u2757\r\n[\r\n    {\"id\":1,\"name\":\"\\u592a\\u90ce\",\"email\":\"taro@example.com\", \uff08...\u7701\u7565\uff09 },\r\n    {\"id\":1,\"name\":\"\\u6b21\\u90ce\",\"email\":\"jiro@example.com\", \uff08...\u7701\u7565\uff09 },\r\n    {\"id\":1,\"name\":\"\\u4e09\\u90ce\",\"email\":\"saburo@example.com\", \uff08...\u7701\u7565\uff09 },\r\n]<\/pre>\n<h2>\u72b6\u614b\u3092\u5909\u5316\u3055\u305b\u3066\u8868\u793a\u3092\u5207\u308a\u66ff\u3048 \u30fb\u30fb\u30fb \u2464<\/h2>\n<p><code>changeState()<\/code>\u306f\u3001<code>state<\/code>\u306e\u4e2d\u8eab\u3092\u5909\u66f4\u3059\u308b\uff08\u3064\u307e\u308a\u3001<code>Vue<\/code>\u304c\u81ea\u52d5\u3067\u8868\u793a\u5207\u308a\u66ff\u3048\u3059\u308b\uff09\u3068\u3044\u3046\u5f79\u5272\u3060\u3051\u3067\u306a\u304f\u3001<code>state<\/code>\u306e\u4e2d\u8eab\u306b\u3088\u3063\u3066\u306f<code>params<\/code>\u306e\u4e2d\u8eab\u3082\u5909\u66f4\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><code>params<\/code>\u306f\u3001Ajax\u9001\u4fe1\u3055\u308c\u308b\uff08\u30e6\u30fc\u30b6\u30fc\u306e\uff09\u30c7\u30fc\u30bf\u3067\u3059\u306e\u3067\u3001\u3053\u3053\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u3067<code>&lt;input&gt;<\/code>\u306e\u4e2d\u8eab\u3082<code>Vue<\/code>\u304c\u81ea\u52d5\u3067\u5909\u66f4\u3057\u3066\u304f\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4fbf\u5229\u3067\u3059\u306d\ud83d\ude0a\ud83d\udc4d<\/p>\n<h2>\u30c7\u30fc\u30bf\u4fdd\u5b58\uff08\u8ffd\u52a0\uff06\u5909\u66f4\uff09 \u30fb\u30fb\u30fb \u2465<\/h2>\n<p><code>onSave()<\/code>\u306f\u3001\u5165\u529b\u30d5\u30a9\u30fc\u30e0\u306e\u300c<strong>\u4fdd\u5b58\u3059\u308b<\/strong>\u300d\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u304c\u3001<strong>\u6ce8\u76ee\u3057\u3066\u307b\u3057\u3044\u306e\u306f\u3001\u300cstate\u300d\u304c\u300ccreate\u300d\u306e\u3068\u304d\u3068\u300cedit\u300d\u306e\u3068\u304d\u3067\u3001URL\u3068\u9001\u4fe1\u30e1\u30bd\u30c3\u30c9\u304c\u9055\u3063\u3066\u304f\u308b\u3068\u3044\u3046\u70b9\u3067\u3059\u3002<\/strong><\/p>\n<p>\u3064\u307e\u308a\u3001\u4eca\u56de\u3067\u3044\u3046\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>create<\/strong><\/p>\n<ul>\n<li>URL\uff1a \/user<\/li>\n<li>\u9001\u4fe1\u30e1\u30bd\u30c3\u30c9\uff1a POST<\/li>\n<li>\u5b9f\u884c\u3055\u308c\u308b\u30e1\u30bd\u30c3\u30c9\uff1a store()<\/li>\n<\/ul>\n<p><strong>edit<\/strong><\/p>\n<ul>\n<li>URL\uff1a \/user\/\uff08\u30e6\u30fc\u30b6\u30fcID\uff09<\/li>\n<li>\u9001\u4fe1\u30e1\u30bd\u30c3\u30c9\uff1a PUT<\/li>\n<li>\u5b9f\u884c\u3055\u308c\u308b\u30e1\u30bd\u30c3\u30c9\uff1a update()<\/li>\n<\/ul>\n<p>\u305d\u3057\u3066\u3001\u4fdd\u5b58\u304c\u5b8c\u4e86\u3059\u308b\u3068\u30da\u30fc\u30b8\u3092\u5f37\u5236\u7684\u306b\u518d\u8aad\u307f\u8fbc\u307f\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30c7\u30fc\u30bf\u524a\u9664 \u30fb\u30fb\u30fb \u2466<\/h2>\n<p><code>onDelete<\/code>\u306f\u3001\u500b\u5225\u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u300c<strong>\u524a\u9664<\/strong>\u300d\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3053\u3061\u3089\u3067\u3082\u524a\u9664\u304c\u5b8c\u4e86\u3057\u305f\u3089\u30da\u30fc\u30b8\u3092\u5f37\u5236\u7684\u306b\u518d\u8aad\u307f\u8fbc\u307f\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u3046\u307e\u304f\u52d5\u304f\u304b\u30c1\u30a7\u30c3\u30af\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<\/p>\n<p>\u307e\u305a\u306f<code>http:\/\/***\/user<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7491\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_1.png\" alt=\"\" width=\"625\" height=\"441\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_1.png 625w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_1-300x212.png 300w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u3068\u30da\u30fc\u30b8\u30ea\u30f3\u30af\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\ud83d\ude0a\ud83d\udc4d<br \/>\n\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\uff12\u30da\u30fc\u30b8\u76ee\u3092\u8868\u793a\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7490\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_2.png\" alt=\"\" width=\"625\" height=\"424\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_2.png 625w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_2-300x204.png 300w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u30da\u30fc\u30b8\u30ea\u30f3\u30af\u3082\u3067\u3059\u304c\u3001\u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u3082\u5185\u5bb9\u304c\u5909\u66f4\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u6b21\u306b\u30da\u30fc\u30b8\u4e0a\u90e8\u306b\u3042\u308b\u300c<strong>\u8ffd\u52a0<\/strong>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u65b0\u3057\u3044\u30e6\u30fc\u30b6\u30fc\u3092\u8ffd\u52a0\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7489\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_3.png\" alt=\"\" width=\"625\" height=\"459\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_3.png 625w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_3-300x220.png 300w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>\u300c<strong>\u4fdd\u5b58\u3059\u308b<\/strong>\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002\u3059\u308b\u3068\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p>\u5148\u307b\u3069\u306e\u30da\u30fc\u30b8\u30ea\u30f3\u30af\u306f\uff13\u307e\u3067\u3067\u3057\u305f\u304c\uff14\u30da\u30fc\u30b8\u76ee\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7488\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_4.png\" alt=\"\" width=\"353\" height=\"73\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_4.png 353w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_4-300x62.png 300w\" sizes=\"auto, (max-width: 353px) 100vw, 353px\" \/><\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u6025\u3044\u3067\uff14\u30da\u30fc\u30b8\u76ee\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u2757<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7487\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_5.png\" alt=\"\" width=\"625\" height=\"303\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_5.png 625w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_5-300x145.png 300w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u5148\u307b\u3069\u767b\u9332\u3057\u305f\u300c<strong>\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc<\/strong>\u300d\u3055\u3093\u304c\u767b\u9332\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u7d9a\u3044\u3066\u300c<strong>\u5909\u66f4\u30dc\u30bf\u30f3<\/strong>\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u3053\u306e\u300c<strong>\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc<\/strong>\u300d\u3055\u3093\u306e\u30c7\u30fc\u30bf\u3092\u5909\u66f4\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7486\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_6.png\" alt=\"\" width=\"625\" height=\"510\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_6.png 625w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_6-300x245.png 300w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>\u300c<strong>\u4fdd\u5b58\u3059\u308b<\/strong>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7485\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_7.png\" alt=\"\" width=\"625\" height=\"297\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_7.png 625w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/06\/laravel_user_management_7-300x143.png 300w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>\u306f\u3044\u2757<\/p>\n<p>\u300c<strong>\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc<\/strong>\u300d\u3055\u3093\u304c\u300c<strong>\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc\uff12<\/strong>\u300d\u3055\u3093\u306b\u5909\u66f4\u306b\u306a\u308a\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3082\u5909\u66f4\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6210\u529f\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<h1>\u3061\u306a\u307f\u306b\u2460\uff1aaxios\u306e\u9001\u4fe1\u65b9\u6cd5\u306b\u3064\u3044\u3066<\/h1>\n<p>\u3053\u308c\u307e\u3067<code>Laravel<\/code>\u306b\u300c<strong>PUT<\/strong>\u300d\u3084\u300c<strong>DELETE<\/strong>\u300d\u30e1\u30bd\u30c3\u30c9\u3067\u9001\u4fe1\u3059\u308b\u5834\u5408\u3001\u300c<strong>_method<\/strong>\u300d\u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u9001\u4fe1\u30e1\u30bd\u30c3\u30c9\u540d\u3092\u5165\u308c\u3066\u9001\u4fe1\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306e\u74b0\u5883\u3067\u8a66\u3057\u3066\u307f\u305f\u3068\u3053\u308d\u3001\u901a\u5e38\u306e<code>PUT<\/code>\uff06<code>DELETE<\/code>\u3067\u3082\u554f\u984c\u306a\u304f\u52d5\u304d\u307e\u3057\u305f\u306e\u3067\u9014\u4e2d\u3067\u5909\u66f4\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u3082\u554f\u984c\u306a\u304f\u52d5\u304f\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre>axios.<strong>put<\/strong>(url, params)\r\n    .then(response =&gt; {\r\n\r\n        \/\/ \u5909\u66f4\u304c\u6210\u529f\u3057\u305f\u6642\r\n\r\n    });<\/pre>\n<h1>\u3061\u306a\u307f\u306b\u2461\uff1a\u524a\u9664\u3057\u305f\u3068\u304d\u306b\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u3089<\/h1>\n<p>\u3082\u3057\u30c7\u30fc\u30bf\u524a\u9664\u3057\u305f\u3068\u304d\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u5834\u5408\u306f\u3001DB\u5185\u306e\u5916\u90e8\u30ad\u30fc\u304c\u539f\u56e0\u3067\u3059\u3002<\/p>\n<pre><strong>Cannot delete or update a parent row: a foreign key constraint fails<\/strong><\/pre>\n<p>\u305d\u306e\u305f\u3081\u3001<code>Laravel<\/code>\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3067\u8a00\u3046\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u90e8\u5206\u3092\u898b\u76f4\u3059\u304b\u3001<\/p>\n<pre><strong>$table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users');<\/strong><\/pre>\n<p>\u3082\u3057\u304f\u306f<code>onDelete('cascade')<\/code>\u3092\u3064\u3051\u3066<code>users<\/code>\u306e\u30c7\u30fc\u30bf\u304c\u524a\u9664\u3055\u308c\u305f\u3089\u9023\u52d5\u3057\u3066\u95a2\u9023\u30c7\u30fc\u30bf\u304c\u524a\u9664\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>$table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users')-&gt;<strong>onDelete('cascade')<\/strong>;<\/pre>\n<p>\u79c1\u306f\u3053\u308c\u3067\u3061\u3087\u3063\u3068\u30cf\u30de\u308a\u307e\u3057\u305f\u30fb\u30fb\u30fb\ud83d\ude02<\/p>\n<h1>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u5b9f\u969b\u306b\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\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3084\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306a\u3069\u306f\u4e00\u5207\u8ffd\u52a0\u3057\u3066\u3044\u307e\u305b\u3093\u306e\u3067\u3054\u81ea\u8eab\u3067\u7528\u610f\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=7494&amp;tmstv=1777532672\" rel=\"nofollow\" id=\"download-link-7494\" data-redirect=\"false\" >\n\tLaravel\u3067\u30e6\u30fc\u30b6\u30fc\u7ba1\u7406\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>Laravel<\/code>\u3067\u30e6\u30fc\u30b6\u30fc\u7ba1\u7406\u30da\u30fc\u30b8\u3092\u300c<strong>\u30df\u30cb\u30de\u30eb<\/strong>\u300d\u4ed5\u69d8\u3067\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u901a\u5e38\u306e\u958b\u767a\u3092\u3059\u308b\u5834\u5408\u306f\u3001\u3057\u3063\u304b\u308a<code>Ajax<\/code>\u7528\u306b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3084\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u610f\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u79c1\u3068\u3057\u3066\u3082\u521d\u306e\u8a66\u307f\u3067\u3057\u305f\u304c\u5fc5\u8981\u6700\u4f4e\u9650\u3067\u3044\u3044\u306a\u3089\u3001\u3053\u308c\u3082OK\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u305f\u3060\u3001\u5192\u982d\u3067\u3082\u66f8\u304d\u307e\u3057\u305f\u30a4\u30f3\u30dd\u30fc\u30c8\u306a\u3069\u306e\u4ed8\u52a0\u6a5f\u80fd\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u305d\u308c\u306a\u308a\u306b\u8907\u96d1\u306b\u306a\u3063\u3066\u304f\u308b\u3053\u3068\u304c\u4e88\u60f3\u3055\u308c\u307e\u3059\u306e\u3067\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3082\u3057\u304f\u306f\u30e1\u30bd\u30c3\u30c9\u306f\u304d\u3063\u3061\u308a\u5206\u3051\u308b\u65b9\u304c\u3044\u3044\u5834\u5408\u3082\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3093\u306a\u30ab\u30f3\u30b8\u3067\u3001\u305c\u3072\u7686\u3055\u3093\u3082\u3084\u3063\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6070 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_5.png\" alt=\"\" width=\"260\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_5.png 260w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_5-244x300.png 244w\" sizes=\"auto, (max-width: 260px) 100vw, 260px\" \/>\u300c\u3084\u3063\u3071\u308a\u30b3\u30fc\u30d2\u30fc\u306f\u3001\u30b4\u30fc\u30eb\u30c9\u30d6\u30ec\u30f3\u30c9\u306e<br \/>\n\u82e6\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u597d\u304d\u3067\u3059\ud83d\udc4d\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u904e\u53bb\u306bLaravel\u3067\u3044\u308d\u3044\u308d\u306a\u30b7\u30b9\u30c6\u30e0\u3092\u958b\u767a\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u304c\u3001\u4e2d\u3067\u3082\u30ed\u30b0\u30a4\u30f3\u304c\u5fc5\u8981\u306a\u30b5\u30a4\u30c8\u3067\u3088\u304f\u3054\u4f9d\u983c\u3092\u3044\u305f\u3060\u304f\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002 \u305d\u308c\u306f\u30fb\u30fb\u30fb &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=7481\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel\u3067\u30e6\u30fc\u30b6\u30fc\u7ba1\u7406\u6a5f\u80fd\u3092\u3064\u304f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":7483,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,12],"tags":[61],"class_list":["post-7481","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-vue-js","tag-61"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/7481","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=7481"}],"version-history":[{"count":10,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/7481\/revisions"}],"predecessor-version":[{"id":7502,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/7481\/revisions\/7502"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/7483"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}