{"id":7292,"date":"2020-05-04T15:00:03","date_gmt":"2020-05-04T06:00:03","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=7292"},"modified":"2020-05-06T16:27:58","modified_gmt":"2020-05-06T07:27:58","slug":"laravel%e3%81%a7%e3%80%8c%e5%85%a5%e8%8d%b7%e3%81%97%e3%81%9f%e3%82%89%e3%83%a1%e3%83%bc%e3%83%ab%e3%81%a7%e3%81%8a%e7%9f%a5%e3%82%89%e3%81%9b%e3%80%8d%e6%a9%9f%e8%83%bd%e3%82%92%e3%81%a4%e3%81%8f","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=7292","title":{"rendered":"Laravel\u3067\u300c\u5165\u8377\u3057\u305f\u3089\u30e1\u30fc\u30eb\u3067\u304a\u77e5\u3089\u305b\u300d\u6a5f\u80fd\u3092\u3064\u304f\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u3068\u3053\u308d\u5916\u51fa\u3092\u3057\u3066\u306a\u3044\u306e\u3067\u5bb6\u306e\u4e2d\u3067\u697d\u3057\u3081\u308b\u65b9\u6cd5\u3092\u6a21\u7d22\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u305d\u3093\u306a\u4e2d\u300c\u4f55\u304b\u3044\u3044\u672c\u3067\u3082\u306a\u3044\u304b\u306a\uff1f\uff08\u30b2\u30fc\u30e0\u542b\u3080\ud83d\udc4d\uff09\u300d\u3068\u3044\u3046\u3053\u3068\u3067\u4e45\u3057\u3076\u308a\u306b<a href=\"https:\/\/www.bookoffonline.co.jp\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u30d6\u30c3\u30af\u30aa\u30d5\u30fb\u30aa\u30f3\u30e9\u30a4\u30f3<\/a>\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3059\u308b\u3068\u3001\u300c<strong>\u3042\u3001\u3053\u308c\u306fLaravel\u3067\u3064\u304f\u3063\u3066\u307f\u305f\u3044\u2757<\/strong>\u300d\u3068\u601d\u3046\u6a5f\u80fd\u306b\u906d\u9047\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u306f\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u300c\u5165\u8377\u3057\u305f\u3089\u30e1\u30fc\u30eb\u3067\u304a\u77e5\u3089\u305b\u300d\u6a5f\u80fd<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u6a5f\u80fd\u306f\u7c21\u5358\u306b\u8a00\u3046\u3068\u300c\u3054\u3081\u3093\u2757\u4eca\u306f\u58f2\u308a\u5207\u308c\u3060\u3051\u3069\u3001\u5165\u8377\u3057\u305f\u3089\u5fc5\u305a\u30e1\u30fc\u30eb\u3067\u77e5\u3089\u305b\u308b\u306d\ud83d\ude0a\u300d\u3068\u3044\u3046\u3082\u306e\u3067\u3001\u5b9f\u306f<strong><code>Laravel<\/code>\u306b\u5099\u308f\u3063\u305f\u6a5f\u80fd\u3092\u4f7f\u3046\u3068\u6bd4\u8f03\u7684\u7c21\u5358\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/strong><\/p>\n<p>\u305d\u3053\u3067\u2757<\/p>\n<p>\u4eca\u56de\u306f\u3053\u306e\u300c<strong>\u5165\u8377\u3057\u305f\u3089\u30e1\u30fc\u30eb\u3067\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb<\/strong>\u300d\u6a5f\u80fd\u306e\u4f5c\u308a\u65b9\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\n\u305c\u3072\u697d\u3057\u307f\u306a\u304c\u3089\u3084\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u2757<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3405 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18.png\" alt=\"\" width=\"310\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18.png 310w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18-291x300.png 291w\" sizes=\"auto, (max-width: 310px) 100vw, 310px\" \/><\/p>\n<p style=\"text-align: center;\">\u300c\u307b\u3057\u3044\u672c\u306f\u307b\u307c\u58f2\u308a\u5207\u308c\u3067\u3057\u305f\ud83d\ude02\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 7.x<\/p>\n<h1>\u3053\u306e\u8a18\u4e8b\u3092\u898b\u305f\u3089\u3067\u304d\u308b\u3053\u3068<\/h1>\n<p><code>items<\/code>\u3068\u3044\u3046\u30c6\u30fc\u30d6\u30eb\u306b\u5546\u54c1\u30c7\u30fc\u30bf\u304c\u767b\u9332\u3057\u3066\u3042\u308a\u3001\u5728\u5eab\uff08<code>stock<\/code>\uff09\u304c\u30bc\u30ed\u306b\u306a\u3063\u305f\u3089\u300c<strong>\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb<\/strong>\u300d\u3092\u767b\u9332\u3059\u308b\u30dc\u30bf\u30f3\u3092\u8868\u793a\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u305d\u306e\u5f8c\u5728\u5eab\u304c\uff11\u4ee5\u4e0a\u306b\u306a\u3063\u305f\u77ac\u9593\u306b\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3078\u300c\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u300d\u9001\u4fe1\u3059\u308b\u3001\u3068\u3044\u3046\u6a5f\u80fd\u3092\u3064\u304f\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u3084\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u2757<\/p>\n<h1>\u524d\u63d0\u3068\u3057\u3066<\/h1>\n<p><code>Laravel<\/code>\u306b\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3001\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc\u304c\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u524d\u63d0\u3067\u3059\u3002<\/p>\n<p>\u3082\u3057\u307e\u3060\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u306a\u3044\u65b9\u306f\u3001\u300c<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>\u300d\u3092\u53c2\u8003\u306b\u3057\u3066\u6e96\u5099\u3092\u6e08\u307e\u305b\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30c6\u30fc\u30d6\u30eb\u306f\u3053\u3093\u306a\u30ab\u30f3\u30b8\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7293\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_1.png\" alt=\"\" width=\"527\" height=\"372\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_1.png 527w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_1-300x212.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/p>\n<h1>\u30e2\u30c7\u30eb\uff06\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u5148\u306b<code>DB<\/code>\u307e\u308f\u308a\u306e\u6e96\u5099\u3092\u3057\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u5fc5\u8981\u306b\u306a\u308b\u30c6\u30fc\u30d6\u30eb\u306f\u4ee5\u4e0b\u306e\uff12\u3064\u3067\u3059\u3002<\/p>\n<ul>\n<li>items\uff1a \u5546\u54c1\u30c7\u30fc\u30bf\u3092\u7ba1\u7406<\/li>\n<li>item_notifications\uff1a \u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u3092\u7ba1\u7406<\/li>\n<\/ul>\n<p>\u307e\u305a\u306f<code>items<\/code>\u30c6\u30fc\u30d6\u30eb\u3067\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:model Item -m<\/strong><\/pre>\n<p>\u5b9f\u884c\u3057\u305f\u3089\u4f5c\u6210\u3055\u308c\u305f\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u958b\u3044\u3066\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><code>\/database\/migrations\/****_**_**_******_create_items_table.php<\/code><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\npublic function up()\r\n{\r\n    Schema::create('items', function (Blueprint $table) {\r\n        $table-&gt;id();\r\n        <strong>$table-&gt;string('name')-&gt;comment('\u5546\u54c1\u540d'); \ud83d\udc48 \u8ffd\u52a0<\/strong>\r\n<strong>        $table-&gt;integer('stock')-&gt;default(0)-&gt;comment('\u5728\u5eab\u6570'); \ud83d\udc48 \u8ffd\u52a0<\/strong>\r\n        $table-&gt;timestamps();\r\n    });\r\n}\r\n\r\n\/\/ \u7701\u7565<\/pre>\n<p>\u305d\u3057\u3066\u3001\u30e2\u30c7\u30eb\u306b\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Item extends Model\r\n{\r\n    <strong>\/\/ \u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7<\/strong>\r\n<strong>    public function notifications() { \/\/ \ud83d\udc48 \u8ffd\u52a0<\/strong>\r\n\r\n<strong>        return $this-&gt;hasMany(\\App\\ItemNotification::class, 'item_id', 'id');<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u6b21\u306b\u3001\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u3092\u7ba1\u7406\u3059\u308b<code>item_notifications<\/code>\u3067\u3059\u3002<br \/>\n\u540c\u3058\u304f\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:model ItemNotification -m<\/strong><\/pre>\n<p>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u4e2d\u8eab\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\n<strong>public function up()<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    Schema::create('item_notifications', function (Blueprint $table) {<\/strong>\r\n<strong>        $table-&gt;id();<\/strong>\r\n<strong>        $table-&gt;unsignedBigInteger('user_id')-&gt;comment('\u30e6\u30fc\u30b6\u30fcID');<\/strong>\r\n<strong>        $table-&gt;unsignedBigInteger('item_id')-&gt;comment('\u5546\u54c1ID');<\/strong>\r\n<strong>        $table-&gt;timestamps();<\/strong>\r\n\r\n<strong>        $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users');<\/strong>\r\n<strong>        $table-&gt;foreign('item_id')-&gt;references('id')-&gt;on('items');<\/strong>\r\n<strong>    });<\/strong>\r\n<strong>}<\/strong>\r\n\r\n\/\/ \u7701\u7565<\/pre>\n<p>\u305d\u3057\u3066\u3001\u3053\u3061\u3089\u306b\u3082\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass ItemNotification extends Model\r\n{\r\n    \/\/ \u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\r\n    <strong>public function user() { \/\/ \ud83d\udc48 \u8ffd\u52a0<\/strong>\r\n\r\n<strong>        return $this-&gt;belongsTo(\\App\\User::class, 'id', 'user_id');<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>php artisan migrate<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u30c6\u30fc\u30d6\u30eb\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7295\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_2.png\" alt=\"\" width=\"351\" height=\"253\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_2.png 351w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_2-300x216.png 300w\" sizes=\"auto, (max-width: 351px) 100vw, 351px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7296\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_3.png\" alt=\"\" width=\"350\" height=\"252\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_3.png 350w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_3-300x216.png 300w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/p>\n<h1>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u3064\u304f\u308b<\/h1>\n<p>\u7d9a\u3044\u3066\u3001<code>items<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3057\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:seed ItemsTableSeeder<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong><code>\/database\/seeds\/ItemsTableSeeder.php<\/code><\/strong><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\npublic function run()\r\n{\r\n    <strong>for($i = 1 ; $i &lt; 25 ; $i++) {<\/strong>\r\n\r\n<strong>        $item = new \\App\\Item();<\/strong>\r\n<strong>        $item-&gt;name = '\u30c6\u30b9\u30c8\u5546\u54c1\u540d - '. $i;\r\n        $item-&gt;stock = rand(0, 10);<\/strong>\r\n<strong>        $item-&gt;save();<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}\r\n\r\n\/\/ \u7701\u7565<\/pre>\n<p>\u3067\u306f\u3001<code>Seeder<\/code>\u3082\u542b\u3081\u3066\u30c6\u30fc\u30d6\u30eb\u3092\u521d\u671f\u5316\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>php artisan migrate:fresh --seed<\/strong><\/pre>\n<p>\u30c6\u30fc\u30d6\u30eb\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7297\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_4.png\" alt=\"\" width=\"542\" height=\"398\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_4.png 542w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_4-300x220.png 300w\" sizes=\"auto, (max-width: 542px) 100vw, 542px\" \/><\/p>\n<h1>\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u3092\u767b\u9332\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5728\u5eab\u304c\u30bc\u30ed\u306e\u5546\u54c1\u306f\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u3092\u767b\u9332\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u30eb\u30fc\u30c8\u3092\u3064\u304f\u308b<\/h2>\n<p><code>Laravel<\/code>\u306bURL\u3092\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>Route::get('items', 'ItemController@index');<\/strong>\r\n<strong>Route::get('ajax\/items', 'ItemController@item_list');<\/strong>\r\n<strong>Route::post('ajax\/items\/register_notification', 'ItemController@register_notification');<\/strong>\r\n<strong>Route::post('ajax\/items\/unregister_notification', 'ItemController@unregister_notification');<\/strong><\/pre>\n<p>\u307e\u305a\uff11\u884c\u76ee\u306e\u30eb\u30fc\u30c8\u306f\u30d6\u30e9\u30a6\u30b6\u3067\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3059\u308b\u90e8\u5206\u3067\u3001\u6b21\u306e\u9805\u76ee\u3067\u3064\u304f\u308b\u30d3\u30e5\u30fc\u3092\u8fd4\u3059\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\uff12\u884c\u76ee\u306f<code>Ajax<\/code>\u3067\u5546\u54c1\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u90e8\u5206\u306b\u306a\u308a\u3001\u6b8b\u308a\uff12\u3064\u306f<code>Ajax<\/code>\u3067\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u306e\u767b\u9332\uff0f\u89e3\u9664\u3092\u3059\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u203b\u306a\u304a\u3001\u4eca\u56de\u306f\u30c6\u30b9\u30c8\u306a\u306e\u3067\u3072\u3068\u3064\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u5b9f\u88c5\u3057\u307e\u3059\u304c\u672c\u6765\u306f\u6a5f\u80fd\u3054\u3068\u306b\u5206\u5272\u3059\u308b\u3053\u3068\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b<\/h2>\n<p>\u7d9a\u3044\u3066\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:controller ItemController<\/strong><\/pre>\n<p>\u305d\u3057\u3066\u4e2d\u8eab\u3092\u6b21\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse Illuminate\\Http\\Request;\r\n\r\nclass ItemController extends Controller\r\n{\r\n    <strong>\/\/ \u30d6\u30e9\u30a6\u30b6\u304b\u3089<\/strong>\r\n    <strong>public function index() {\r\n\r\n        return view('items');\r\n\r\n    }\r\n\r\n    \/\/ \u4ee5\u964d\u306fAjax\r\n    public function item_list() {\r\n\r\n        return \\App\\Item::with('notifications')-&gt;get();\r\n\r\n    }\r\n\r\n    public function register_notification(Request $request) { \/\/ \u2460\r\n\r\n        $result = false;\r\n        $user = $request-&gt;user();\r\n        $exists = \\App\\ItemNotification::where('user_id', $user-&gt;id)\r\n            -&gt;where('item_id', $request-&gt;item_id)\r\n            -&gt;exists();\r\n\r\n        if(!$exists) {\r\n\r\n            $notification = new \\App\\ItemNotification();\r\n            $notification-&gt;user_id = $user-&gt;id;\r\n            $notification-&gt;item_id = $request-&gt;item_id;\r\n            $result = $notification-&gt;save();\r\n\r\n        }\r\n\r\n        return ['result' =&gt; $result];\r\n\r\n    }\r\n\r\n    public function unregister_notification(Request $request) { \/\/ \u2461\r\n\r\n        $user = $request-&gt;user();\r\n        $query = \\App\\ItemNotification::where('user_id', $user-&gt;id)\r\n            -&gt;where('item_id', $request-&gt;item_id);\r\n\r\n        if($query-&gt;exists()) {\r\n\r\n            $result = ($query-&gt;delete() === 1);\r\n\r\n        }\r\n\r\n        return ['result' =&gt; $result];\r\n\r\n    }<\/strong>\r\n}<\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u91cd\u8981\u306a\u306e\u304c\u3001\u4ee5\u4e0b\uff12\u3064\u3067\u3059\u3002<\/p>\n<p><strong>\u2460register_notification<\/strong><\/p>\n<p>\u3053\u306e\u4e2d\u3067\u3001\u3042\u308b\u5546\u54c1\u306e\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u3092\u767b\u9332\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u6d41\u308c\u3068\u3057\u3066\u306f\u3001\u307e\u305a\u300c<strong>\u5546\u54c1ID<\/strong>\u300d\u3068\u300c<strong>\u30e6\u30fc\u30b6\u30fcID<\/strong>\u300d\u3092\u4f7f\u3063\u3066\u3059\u3067\u306b\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3001\u3082\u3057\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3057\u3066\u306a\u3044\u306a\u3089\u65b0\u898f\u8ffd\u52a0\u3059\u308b\u3068\u3044\u3046\u5f62\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>\u2461unregister_notification<\/strong><\/p>\n<p>\u4e0a\u306e<code>register_notification()<\/code>\u3068\u307b\u307c\u540c\u3058\u3067\u3059\u304c\u3001\u3053\u3061\u3089\u306f\u5b58\u5728\u30c1\u30a7\u30c3\u30af\u3068\u524a\u9664\u3092\u3072\u3068\u3064\u306e\u30af\u30a8\u30ea\u30fc\u3067\u5b9f\u88c5\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u3064\u307e\u308a\u3001\u30b3\u30fc\u30c9\u3092\u7701\u7565\u3057\u3066\u697d\u3057\u307e\u3057\u305f\ud83d\udc4d\uff09<\/p>\n<h2>\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308b<\/h2>\n<p>\u7d9a\u3044\u3066\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<pre>&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;link href=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.4.1\/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-3\"&gt;\r\n        &lt;h3 class=\"mb-3\"&gt;\u300c\u5165\u8377\u3057\u305f\u3089\u30e1\u30fc\u30eb\u3067\u304a\u77e5\u3089\u305b\u300d\u30b7\u30b9\u30c6\u30e0\u30fb\u30b5\u30f3\u30d7\u30eb&lt;\/h3&gt;\r\n        @if(!auth()-&gt;check())\r\n            &lt;div class=\"alert alert-danger\"&gt;\r\n                &lt;a href=\"\/login\"&gt;\u30ed\u30b0\u30a4\u30f3&lt;\/a&gt;\u3057\u3066\u304f\u3060\u3055\u3044\u3002\r\n            &lt;\/div&gt;\r\n        @endif\r\n        &lt;table class=\"table table-bordered\"&gt;\r\n            &lt;thead class=\"bg-secondary text-white\"&gt;\r\n                &lt;tr&gt;\r\n                    &lt;th class=\"text-nowrap\"&gt;\u5546\u54c1\u540d&lt;\/th&gt;\r\n                    &lt;th class=\"text-nowrap\"&gt;\u5728\u5eab\u6570&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=\"i in items\"&gt;\r\n                    &lt;td class=\"w-100\" v-text=\"i.name\"&gt;&lt;\/td&gt;\r\n                    &lt;td v-text=\"i.stock\"&gt;&lt;\/td&gt;\r\n                    &lt;td class=\"text-right text-nowrap\"&gt;\r\n                        &lt;button\r\n                            type=\"button\"\r\n                            class=\"btn btn-sm btn-light\"\r\n                            v-if=\"showRegistrationButton(i)\"\r\n                            @click=\"registerNotification(i.id)\"&gt;\u5165\u8377\u3057\u305f\u3089\u30e1\u30fc\u30eb\u3067\u304a\u77e5\u3089\u305b&lt;\/button&gt;\r\n                        &lt;button\r\n                            type=\"button\"\r\n                            class=\"btn btn-sm btn-secondary\"\r\n                            v-if=\"showUnregistrationButton(i)\"\r\n                            @click=\"unregisterNotification(i.id)\"&gt;\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u3092\u89e3\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    &lt;\/div&gt;\r\n    &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/vue\/2.6.11\/vue.min.js\"&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                items: [],\r\n                userId: parseInt('{{ auth()-&gt;user()-&gt;id ?? -1 }}')\r\n            },\r\n            methods: {\r\n                getItems() {\r\n\r\n                    axios.get('\/ajax\/items')\r\n                        .then(response =&gt; {\r\n\r\n                            this.items = response.data;\r\n\r\n                        });\r\n\r\n                },\r\n                showRegistrationButton(item) {\r\n\r\n                    if(parseInt(item.stock) &gt; 0 || this.userId === -1) {\r\n\r\n                        return false;\r\n\r\n                    }\r\n\r\n                    for(let notification of item.notifications) {\r\n\r\n                        if(notification.user_id === this.userId) {\r\n\r\n                            return false;\r\n\r\n                        }\r\n\r\n                    }\r\n\r\n                    return true;\r\n\r\n                },\r\n                showUnregistrationButton(item) {\r\n\r\n                    if(parseInt(item.stock) &gt; 0 || this.userId === -1) {\r\n\r\n                        return false;\r\n\r\n                    }\r\n\r\n                    for(let notification of item.notifications) {\r\n\r\n                        if(notification.user_id === this.userId) {\r\n\r\n                            return true;\r\n\r\n                        }\r\n\r\n                    }\r\n\r\n                    return false;\r\n\r\n                },\r\n                registerNotification(itemId) {\r\n\r\n                    const url = '\/ajax\/items\/register_notification';\r\n                    const params = {\r\n                        item_id: itemId\r\n                    };\r\n                    axios.post(url, params)\r\n                        .then(response =&gt; {\r\n\r\n                            if(response.data.result === true) {\r\n\r\n                                alert('\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u306e\u767b\u9332\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002');\r\n                                this.getItems();\r\n\r\n                            }\r\n\r\n                        });\r\n\r\n                },\r\n                unregisterNotification(itemId) {\r\n\r\n                    const url = '\/ajax\/items\/unregister_notification';\r\n                    const params = {\r\n                        item_id: itemId\r\n                    };\r\n                    axios.post(url, params)\r\n                        .then(response =&gt; {\r\n\r\n                            if(response.data.result === true) {\r\n\r\n                                alert('\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u306e\u89e3\u9664\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002');\r\n                                this.getItems();\r\n\r\n                            }\r\n\r\n                        });\r\n\r\n                },\r\n\r\n            },\r\n            mounted() {\r\n\r\n                this.getItems();\r\n\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\u3084\u3063\u3066\u3044\u308b\u306e\u306f\u3001\u30c7\u30fc\u30bf\u306e\u30ea\u30b9\u30c8\u8868\u793a\u3068<strong>\u300c\u5fc5\u8981\u304c\u3042\u308c\u3070\u300d\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u767b\u9332\u30dc\u30bf\u30f3\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/strong><\/p>\n<p>\u305d\u3057\u3066\u3001\u305d\u306e\u5fc5\u8981\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u306e\u6761\u4ef6\u306f\u3001<\/p>\n<ul>\n<li>\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b<\/li>\n<li>\u5546\u54c1\u306e\u5728\u5eab\u304c\u30bc\u30ed<\/li>\n<li>\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u308b\u30e6\u30fc\u30b6\u30fc\u306f\u307e\u3060\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u3092\u767b\u9332\u3057\u3066\u306a\u3044<\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u3082\u306e\u3067\u3001<code>showRegistrationButton()<\/code>\u3067\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u9006\u306b\u89e3\u9664\u30dc\u30bf\u30f3\u306e\u6761\u4ef6\u306f\u3001<\/p>\n<ul>\n<li>\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b<\/li>\n<li>\u5546\u54c1\u306e\u5728\u5eab\u304c\u30bc\u30ed<\/li>\n<li>\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u308b\u30e6\u30fc\u30b6\u30fc\u304c\u4e8b\u524d\u306b\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u3092\u767b\u9332\u3057\u3066\u3044\u308b<\/li>\n<\/ul>\n<p>\u3067\u3001\u3053\u3061\u3089\u306f<code>showUnregistrationButton()<\/code>\u304c\u8a72\u5f53\u3059\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<h1>\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u6700\u5f8c\u306b\u5546\u54c1\u304c\u5165\u8377\u3057\u305f\uff08<code>items<\/code>\u30c6\u30fc\u30d6\u30eb\u306e<code>stock<\/code>\u304c\u30bc\u30ed\u3067\u306f\u306a\u304f\u306a\u3063\u305f\uff09\u77ac\u9593\u306b\u30e1\u30fc\u30eb\u9001\u4fe1\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u30e1\u30fc\u30eb\u9001\u4fe1\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001\u5148\u306b\u30e1\u30fc\u30eb\u9001\u4fe1\u3059\u308b\u90e8\u5206\u3067\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067<code>Mailable<\/code>\uff08Laravel\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u6a5f\u80fd\uff09\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>php artisan make:mail ItemArrived<\/strong><\/pre>\n<p>\u4e2d\u8eab\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong><code>\/app\/Mail\/ItemArrived.php<\/code><\/strong><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\n<strong>public function build()<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    return $this-&gt;subject('\u5546\u54c1\u304c\u5165\u8377\u3057\u307e\u3057\u305f\uff01')<\/strong>\r\n<strong>        -&gt;from('arrival@example.com')<\/strong>\r\n<strong>        -&gt;text('emails.item_arrived')<\/strong>\r\n<strong>        -&gt;with('item', $this-&gt;item);<\/strong>\r\n<strong>}<\/strong>\r\n\r\n\/\/ \u7701\u7565<\/pre>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u4e2d\u3067\u8a2d\u5b9a\u3057\u305f\u30e1\u30fc\u30eb\u6587\u9762\u306e\u30d3\u30e5\u30fc\u3082\u3064\u304f\u308a\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong><code>\/resources\/views\/emails\/item_arrived.blade.php<\/code><\/strong><\/p>\n<pre>\u5546\u54c1\u304c\u5165\u8377\u3057\u307e\u3057\u305f\u306e\u3067\u3054\u5831\u544a\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\uff01\r\n\r\n\u3010\u5165\u8377\u3057\u305f\u5546\u54c1\u3011 {{ $item-&gt;name }}\r\n\r\n\uff08\u3053\u3053\u306b\u5546\u54c1\u306eURL\u306a\u3069\uff09\r\n\r\n-------------------------------\r\n\r\nConsole dot Log\r\nhttps:\/\/blog.capilano-fw.com<\/pre>\n<h2>\u30a4\u30d9\u30f3\u30c8\u3092\u3064\u304f\u308b<\/h2>\n<p>\u7d9a\u3044\u3066\u3001<code>ItemSaved<\/code>\u3068\u3044\u3046\u30a4\u30d9\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:event ItemSaved<\/strong><\/pre>\n<p>\u305d\u3057\u3066\u3001\u4e2d\u8eab\u3092\u6b21\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><code><strong>\/app\/Events\/ItemSaved.php<\/strong><\/code><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\n<strong>public function __construct(Item $item)<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    $old_stock = intval($item-&gt;getOriginal('stock'));<\/strong>\r\n<strong>    $new_stock = intval($item-&gt;stock);<\/strong>\r\n\r\n<strong>    if($old_stock === 0 &amp;&amp; $new_stock &gt; 0) {    \/\/ \u4fdd\u5b58\u524d\u306f\u30bc\u30ed\u3060\u3063\u305f\u3051\u3069\u3001\u4eca\u306f\uff11\u4ee5\u4e0a\u3042\u308b\u3068\u304d<\/strong>\r\n\r\n<strong>        foreach($item-&gt;notifications as $notification) {<\/strong>\r\n\r\n<strong>            $user = $notification-&gt;user;<\/strong>\r\n<strong>            \\Mail::to($user)-&gt;send(new ItemArrived($item)); \/\/ \u30e1\u30fc\u30eb\u9001\u4fe1<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n<strong>}<\/strong>\r\n\r\n\/\/ \u7701\u7565<\/pre>\n<p>\u305d\u3057\u3066\u3001\u4f5c\u6210\u3057\u305f<code>ItemSaved<\/code>\u3092<code>Item<\/code>\u30e2\u30c7\u30eb\u306b\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse App\\Events\\ItemSaved;\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Item extends Model\r\n{\r\n    <strong>protected $dispatchesEvents = [ \/\/ \ud83d\udc48 \u8ffd\u52a0<\/strong>\r\n<strong>        'saved' =&gt; ItemSaved::class \/\/ \u4fdd\u5b58\u5f8c\u306b\u5b9f\u884c<\/strong>\r\n<strong>    ];<\/strong>\r\n\r\n    \/\/ \u7701\u7565\r\n}<\/pre>\n<p>\u3053\u308c\u3067\u30e1\u30fc\u30eb\u9001\u4fe1\u90e8\u5206\u3082\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u304b\u3089\u300c<strong>http:\/\/*****\/items<\/strong>\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7307\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_5.png\" alt=\"\" width=\"485\" height=\"596\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_5.png 485w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_5-244x300.png 244w\" sizes=\"auto, (max-width: 485px) 100vw, 485px\" \/><\/p>\n<p><strong>\u5728\u5eab\u6570\u304c\u30bc\u30ed\u306e\u3082\u306e\u3060\u3051\u300c\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u300d\u30dc\u30bf\u30f3\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/strong><\/p>\n<p>\u3067\u306f\u3001\u300c\u30c6\u30b9\u30c8\u5546\u54c1\u540d &#8211; 4\u300d\u306e\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7306\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_6.png\" alt=\"\" width=\"485\" height=\"444\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_6.png 485w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_6-300x275.png 300w\" sizes=\"auto, (max-width: 485px) 100vw, 485px\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u30a2\u30e9\u30fc\u30c8\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7305\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_7.png\" alt=\"\" width=\"443\" height=\"131\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_7.png 443w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_7-300x89.png 300w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/p>\n<p>\u305d\u3057\u3066\u3001\u30dc\u30bf\u30f3\u304c\u89e3\u9664\u7528\u306b\u5909\u66f4\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7304\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_8.png\" alt=\"\" width=\"485\" height=\"445\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_8.png 485w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_8-300x275.png 300w\" sizes=\"auto, (max-width: 485px) 100vw, 485px\" \/><\/p>\n<p>\u3053\u306e\u6642\u3001<code>item_notifications<\/code>\u306f\u3053\u3046\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7303\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_9.png\" alt=\"\" width=\"495\" height=\"269\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_9.png 495w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_9-300x163.png 300w\" sizes=\"auto, (max-width: 495px) 100vw, 495px\" \/><\/p>\n<p>\u3067\u306f\u6b21\u306b\u3001\u89e3\u9664\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7302\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_10.png\" alt=\"\" width=\"443\" height=\"131\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_10.png 443w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_10-300x89.png 300w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/p>\n<p>\u3059\u308b\u3068\u89e3\u9664\u306e\u30a2\u30e9\u30fc\u30c8\u304c\u8868\u793a\u3055\u308c\u3066\u3001\u89e3\u9664\u30dc\u30bf\u30f3\u306f\u767b\u9332\u30dc\u30bf\u30f3\u306b\u623b\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7301\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_11.png\" alt=\"\" width=\"485\" height=\"444\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_11.png 485w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_11-300x275.png 300w\" sizes=\"auto, (max-width: 485px) 100vw, 485px\" \/><\/p>\n<p>\u6210\u529f\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<p>\u7d9a\u3044\u3066\u30e1\u30fc\u30eb\u304c\u5b9f\u969b\u306b\u9001\u4fe1\u3055\u308c\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<br \/>\n\u30eb\u30fc\u30c8\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong><code>\/routes\/web.php<\/code><\/strong><\/p>\n<pre>Route::get('items\/test', function(){\r\n\r\n<strong>    $item = \\App\\Item::find(8); \/\/ \ud83d\udc48 \u8a72\u5f53\u3059\u308b\u5546\u54c1ID\u3078\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044<\/strong>\r\n<strong>    $item-&gt;stock = 20; \/\/ 20\u500b\u5165\u8377<\/strong>\r\n<strong>    $item-&gt;save();<\/strong>\r\n\r\n});<\/pre>\n<p>\u305d\u3057\u3066\u3001\u3082\u3046\u4e00\u5ea6\u300c\u304a\u77e5\u3089\u305b\u30e1\u30fc\u30eb\u300d\u3092\u767b\u9332\u3057\u3066\u300c<strong>http:\/*****\/items\/test<\/strong>\u300d\u306b\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u5b9f\u884c\u3059\u308b\u3068\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7314\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_12.png\" alt=\"\" width=\"417\" height=\"369\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_12.png 417w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/05\/laravel_arrival_notification_12-300x265.png 300w\" sizes=\"auto, (max-width: 417px) 100vw, 417px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u3053\u3061\u3089\u3082\u3046\u307e\u304f\u30e1\u30fc\u30eb\u9001\u4fe1\u3055\u308c\u307e\u3057\u305f\ud83d\ude09<\/p>\n<h1>\u6559\u6750\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u5b9f\u969b\u306b\u958b\u767a\u3057\u305f\u6559\u6750\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=7317&amp;tmstv=1777527173\" rel=\"nofollow\" id=\"download-link-7317\" data-redirect=\"false\" >\n\t\u300c\u5165\u8377\u3057\u305f\u3089\u30e1\u30fc\u30eb\u3067\u304a\u77e5\u3089\u305b\u300d\u6a5f\u80fd\u3092\u3064\u304f\u308b<\/a>\n\n<p>\u203b\u305f\u3060\u3057\u3001\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306a\u3069\u306f\u3054\u81ea\u8eab\u3067\u5b9f\u884c\u3057\u3066\u3044\u305f\u3060\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u30d6\u30c3\u30af\u30aa\u30d5\u30fb\u30aa\u30f3\u30e9\u30a4\u30f3\u306b\u5f71\u97ff\u3055\u308c\u3066\u300c<strong>\u5165\u8377\u3057\u305f\u3089\u30e1\u30fc\u30eb\u3067\u304a\u77e5\u3089\u305b<\/strong>\u300d\u6a5f\u80fd\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u6a5f\u80fd\u3092\u4f7f\u3048\u3070\u3001\u3044\u3061\u65e9\u304f\u8cb7\u3044\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u308b\u4eba\u306b\u304a\u77e5\u3089\u305b\u3067\u304d\u307e\u3059\u3057\u3001\u696d\u52d9\u30b7\u30b9\u30c6\u30e0\u306b\u3082\u5fdc\u7528\u304c\u3067\u304d\u308b\u3093\u3058\u3083\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u30c1\u30e3\u30ec\u30f3\u30b8\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6068 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_12.png\" alt=\"\" width=\"226\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_12.png 226w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_12-212x300.png 212w\" sizes=\"auto, (max-width: 226px) 100vw, 226px\" \/><\/p>\n<p style=\"text-align: center;\">\u300c\u305d\u3046\u3044\u3048\u3070\u3001\u68da\u306b<br \/>\n\u8aad\u3093\u3067\u306a\u3044\u5c0f\u8aac\u304c\u7720\u3063\u3066\u307e\u3057\u305f\ud83d\ude09\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u3068\u3053\u308d\u5916\u51fa\u3092\u3057\u3066\u306a\u3044\u306e\u3067\u5bb6\u306e\u4e2d\u3067\u697d\u3057\u3081\u308b\u65b9\u6cd5\u3092\u6a21\u7d22\u3057\u3066\u3044\u307e\u3059\u3002 \u305d\u3057\u3066\u3001\u305d\u3093\u306a\u4e2d\u300c\u4f55\u304b\u3044\u3044\u672c\u3067\u3082\u306a\u3044\u304b\u306a\uff1f\uff08\u30b2\u30fc\u30e0\u542b\u3080\ud83d\udc4d\uff09\u300d\u3068\u3044\u3046\u3053\u3068\u3067\u4e45\u3057\u3076\u308a\u306b &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=7292\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel\u3067\u300c\u5165\u8377\u3057\u305f\u3089\u30e1\u30fc\u30eb\u3067\u304a\u77e5\u3089\u305b\u300d\u6a5f\u80fd\u3092\u3064\u304f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":7309,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,97],"tags":[81],"class_list":["post-7292","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-97","tag-81"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/7292","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=7292"}],"version-history":[{"count":14,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/7292\/revisions"}],"predecessor-version":[{"id":7340,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/7292\/revisions\/7340"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/7309"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}