{"id":9251,"date":"2021-06-28T07:00:22","date_gmt":"2021-06-27T22:00:22","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=9251"},"modified":"2021-06-08T17:20:39","modified_gmt":"2021-06-08T08:20:39","slug":"laravel-%e3%81%a7%e3%80%8c%e6%9c%89%e5%8a%b9%e6%9c%9f%e9%99%90%e3%81%a4%e3%81%8d%e3%80%8d%e3%83%9d%e3%82%a4%e3%83%b3%e3%83%88%e3%82%b7%e3%82%b9%e3%83%86%e3%83%a0%e3%82%92%e3%81%a4%e3%81%8f%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=9251","title":{"rendered":"Laravel \u3067\u300c\u6709\u52b9\u671f\u9650\u3064\u304d\u300d\u30dd\u30a4\u30f3\u30c8\u30b7\u30b9\u30c6\u30e0\u3092\u3064\u304f\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u308c\u306f\u500b\u4eba\u7684\u306a\u8a71\u306a\u306e\u3067\u3059\u304c\u3001\u304a\u8cb7\u3044\u7269\u306e\u3068\u304d\u300c<strong>\u30dd\u30a4\u30f3\u30c8\u30ab\u30fc\u30c9\u3064\u304f\u308a\u307e\u3059\u304b\u2753<\/strong>\u300d\u3068\u805e\u304b\u308c\u3066\u3082\u3001\u300c\u30dd\u30a4\u30f3\u30c8\u304c\u3042\u308b\u3053\u3068\u3067\u5224\u65ad\u304c\u920d\u308b\u5834\u5408\u300d\u306f\u65ad\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\uff08\u30d3\u30d3\u30ea\u306a\u306e\u3067\u300c\u30dd\u30a4\u30f3\u30c8\u3042\u308b\u304b\u3089\u30e0\u30ea\u3057\u3066\u8cb7\u308f\u306a\u304d\u3083\uff01\u300d\u3063\u3066\u306a\u308a\u305f\u304f\u306a\u3044\u308f\u3051\u3067\u3059\ud83d\ude02\uff09<\/p>\n<p>\u3068\u306f\u8a00\u3063\u3066\u3082\u3001\u30dd\u30a4\u30f3\u30c8\u3092\u3046\u307e\u304f\u4f7f\u3046\u3068<strong>\u304a\u5f97\u306a\u8cb7\u3044\u7269\u304c\u3067\u304d\u307e\u3059<\/strong>\u3057\u3001\u304a\u5e97\u5074\u304b\u3089\u3059\u308b\u3068\u5ba2\u306e\u884c\u52d5\u30d1\u30bf\u30fc\u30f3\u3092\u77e5\u308b\u305f\u3081\u306b\u3068\u3066\u3082\u6709\u52b9\u3060\u3063\u305f\u308a\u3057\u307e\u3059\u3088\u306d\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u3053\u306e\u30dd\u30a4\u30f3\u30c8\u30fb\u30b7\u30b9\u30c6\u30e0\u3092<code>Laravel<\/code>\u3067\u3064\u304f\u3063\u3066\u307f\u305f\u3044\u306e\u3067\u3059\u304c\u3001<strong>\u3069\u3053\u3067\u3082\u3042\u308b\u3088\u3046\u306a\u300c\u8caf\u3081\u3066\uff06\u4f7f\u3063\u3066\u300d\u3060\u3051\u306e\u3082\u306e\u3067\u306f\u9762\u767d\u304f\u306a\u3044<\/strong>\u3068\u611f\u3058\u307e\u3057\u305f\u306e\u3067\u3001\u3068\u3042\u308b\u6a5f\u80fd\u3082\u8ffd\u52a0\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u306f\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001\u697d\u5929\u3067\u3082\u63a1\u7528\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u300c<strong>\u3042\u308b\u671f\u9593\u3060\u3051\u4f7f\u3048\u308b\u30dd\u30a4\u30f3\u30c8<\/strong>\u300d\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u300c<strong>\u3048\u3063\u3001\u3058\u3083\u3042\u2757\u2753<\/strong>\u300d\u3068\u601d\u3063\u305f\u65b9\u306f\u52d8\u304c\u3044\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u8907\u6570\u306e\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8\u304c\u3042\u308b\u5834\u5408\u3001\u697d\u5929\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote><p>\uff08\u5f15\u7528\uff09<br \/>\n\u8907\u6570\u306e\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8\u3092\u4fdd\u6709\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u3001<span style=\"text-decoration: underline;\">\u6709\u52b9\u671f\u9650\u306e\u8fd1\u3044\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8\u304b\u3089\u512a\u5148\u3057\u3066\u4f7f\u308f\u308c\u307e\u3059\u3002<\/span><\/p><\/blockquote>\n<p>\u3064\u307e\u308a\u3001\u300c<strong>\u30e6\u30fc\u30b6\u30fc\u304c\u4e00\u756a\u640d\u3092\u3057\u306a\u3044\u30d1\u30bf\u30fc\u30f3<\/strong>\u300d\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306d\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>Laravel<\/code>\u3067\u300c<strong>\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8 + \u6c38\u4e45\u30dd\u30a4\u30f3\u30c8<\/strong>\u300d\u304c\u5165\u308a\u6df7\u3058\u3063\u305f\u30dd\u30a4\u30f3\u30c8\u30fb\u30b7\u30b9\u30c6\u30e0\u3092\u3064\u304f\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u4f55\u304b\u306e\u53c2\u8003\u306b\u306a\u308a\u307e\u3057\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\u3002\ud83d\ude0a\u2728<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8777 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/03\/no_15.png\" alt=\"\" width=\"338\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/03\/no_15.png 338w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/03\/no_15-300x284.png 300w\" sizes=\"auto, (max-width: 338px) 100vw, 338px\" \/>\u300c\u6e7f\u5ea6\u304c\u4e0a\u304c\u308b\u3068\u3001<br \/>\n\u9aea\u306e\u6bdb\u30af\u30ea\u30c3\u30af\u30ea\u2026\ud83d\ude2b\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 8.x\u3001Vue 3\u3001Bootstrap 5<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u4eca\u56de\u5b9f\u73fe\u3057\u305f\u3044\u306e\u306f\u3001\u300c<strong>\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8<\/strong>\u300d\u3068\u300c<strong>\u6c38\u4e45\u30dd\u30a4\u30f3\u30c8<\/strong>\u300d\u304c\u5165\u308a\u6df7\u3058\u3063\u305f\u72b6\u614b\u306a\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u30b9\u30c8\u30fc\u30ea\u30fc\u3067\u30dd\u30a4\u30f3\u30c8\u64cd\u4f5c\u3057\u3001\u3046\u307e\u304f\u51e6\u7406\u3067\u304d\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li>7\u65e5\u5f8c\u306b\u6709\u52b9\u671f\u9650\u304c\u5207\u308c\u308b\u300c\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8\u300d300\u30dd\u30a4\u30f3\u30c8\u3092\u30b2\u30c3\u30c8<\/li>\n<li>10\u65e5\u5f8c\u306b\u6709\u52b9\u671f\u9650\u304c\u5207\u308c\u308b\u300c\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8\u300d500\u30dd\u30a4\u30f3\u30c8\u3092\u30b2\u30c3\u30c8<\/li>\n<li>\u3044\u3064\u3067\u3082\u4f7f\u3048\u308b\u300c\u6c38\u4e45\u30dd\u30a4\u30f3\u30c8\u300d700\u30dd\u30a4\u30f3\u30c8\u3092\u30b2\u30c3\u30c8<\/li>\n<li>500\u30dd\u30a4\u30f3\u30c8\u3092\u4f7f\u7528<\/li>\n<li>\u4fdd\u6301\u30dd\u30a4\u30f3\u30c8\u306f\uff1f<\/li>\n<li>\uff0815\u65e5\u5f8c\u304c\u7d4c\u904e\uff09\u4fdd\u6301\u30dd\u30a4\u30f3\u30c8\u306f\uff1f<\/li>\n<\/ol>\n<p>\u3064\u307e\u308a\u3001\u4fdd\u6709\u30dd\u30a4\u30f3\u30c8\u306e\u52d5\u304d\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ol>\n<li>300 P<\/li>\n<li>300 + 500 = 800 P<\/li>\n<li>300 + 500 + 700 = 1,500 P<\/li>\n<li>1,500 &#8211; 500 = 1,000 P\uff08\u671f\u9593\u9650\u5b9a: 300 P, \u6c38\u4e45\u30dd\u30a4\u30f3\u30c8: 700 P\uff09<\/li>\n<li>\u4fdd\u6301\u30dd\u30a4\u30f3\u30c8\u306f 1,000 P<\/li>\n<li>\uff0815\u65e5\u5f8c\u304c\u7d4c\u904e\uff09\u4fdd\u6301\u30dd\u30a4\u30f3\u30c8\u306f 1,000 P &#8211; 300 P = 700 P\uff08\u6c38\u4e45\u30dd\u30a4\u30f3\u30c8\u306e\u307f\uff09<\/li>\n<\/ol>\n<p>\u3053\u308c\u3092\u5b9f\u73fe\u3059\u308b\u30dd\u30a4\u30f3\u30c8\u30fb\u30b7\u30b9\u30c6\u30e0\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3059\u2757<\/p>\n<h1><span id=\"i\">\u524d\u63d0\u3068\u3057\u3066<\/span><\/h1>\n<p>\u4eca\u56de\u3082\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff06\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc\u304c<code>users<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u524d\u63d0\u3067\u3059\u3002<\/p>\n<p>\u3082\u3057\u307e\u3060\u306e\u65b9\u306f\u4ee5\u4e0b\u3092\u53c2\u8003\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\ud83d\udcdd\u00a0\u53c2\u8003\u30da\u30fc\u30b8<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/blog.capilano-fw.com\/?p=8301\">Laravel Breeze\u3067\u300c\u30b7\u30f3\u30d7\u30eb\u306a\u300d\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/a><\/li>\n<li><a href=\"https:\/\/blog.capilano-fw.com\/?p=7827\">Laravel8.x\u4ee5\u964d\u3067\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u65b9\u6cd5<\/a><\/li>\n<\/ul>\n<h1>\u30e2\u30c7\u30eb\uff06\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u307e\u305a\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5468\u308a\u304b\u3089\u3064\u304f\u3063\u3066\u3044\u304d\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:model Point -m<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u30d5\u30a1\u30a4\u30eb\u304c\uff12\u3064\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u305d\u308c\u305e\u308c\u6b21\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong>database\/migrations\/****_**_**_******_create_points_table.php<\/strong><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\n    public function up()\r\n    {\r\n        Schema::create('points', function (Blueprint $table) {\r\n            $table-&gt;id();\r\n            <strong>$table-&gt;unsignedBigInteger('user_id')-&gt;comment('\u30e6\u30fc\u30b6\u30fcID');<\/strong>\r\n<strong>            $table-&gt;unsignedInteger('points_added')-&gt;default(0)-&gt;comment('\u53d6\u5f97\u3057\u305f\u30dd\u30a4\u30f3\u30c8');<\/strong>\r\n<strong>            $table-&gt;unsignedInteger('points_used')-&gt;default(0)-&gt;comment('\u5229\u7528\u6e08\u307f\u30dd\u30a4\u30f3\u30c8');<\/strong>\r\n<strong>            $table-&gt;dateTime('expired_at')-&gt;nullable()-&gt;comment('\u6709\u52b9\u671f\u9650');<\/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        });\r\n    }\r\n\r\n\/\/ \u7701\u7565<\/pre>\n<p>\u306a\u304a\u3001\u4eca\u56de\u306e\u3084\u308a\u304b\u305f\u306f\u300c<strong>\uff11\u30ec\u30b3\u30fc\u30c9\u305a\u3064\u3067\u5b8c\u7d50\u3059\u308b\u30d1\u30bf\u30fc\u30f3<\/strong>\u300d\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3064\u307e\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u307e\u305a\u30dd\u30a4\u30f3\u30c8\u3092\u7372\u5f97\u3057\u305f\u6642\u306b\uff11\u884c\u30ec\u30b3\u30fc\u30c9\u3092\u7528\u610f\u3057\u3001\u3082\u3057\u4f7f\u7528\u3055\u308c\u305f\u3089\u3001\u53f3\u5074\u306e\u5229\u7528\u6e08\u307f\u30dd\u30a4\u30f3\u30c8\u3092\u66f8\u304d\u63db\u3048\u3066\u3044\u304f\u3068\u3044\u3046\u6d41\u308c\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9255\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_1.png\" alt=\"\" width=\"525\" height=\"260\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_1.png 525w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_1-300x149.png 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/p>\n<h1>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u300c<strong>\u3084\u308a\u305f\u3044\u3053\u3068<\/strong>\u300d\u3067\u7d39\u4ecb\u3057\u305f\u30b9\u30c8\u30fc\u30ea\u30fc\u3092\u305f\u3069\u308b\u3088\u3046\u306b\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b \u4eca\u56de\u306f\u30c6\u30b9\u30c8\u3067\u3059\u306e\u3067\uff11\u4eba\u306e\u30e6\u30fc\u30b6\u30fc\u3060\u3051\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u3064\u304f\u308a\u307e\u3059\u3002<br \/>\n\u203b \u307e\u305f\u3001\u30dd\u30a4\u30f3\u30c8\u3092\u4f7f\u3046\u90e8\u5206\u306f\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3057\u307e\u3059\u306e\u3067\u3001\u300c\u30dd\u30a4\u30f3\u30c8\u3092\u4f7f\u3063\u305f\u300d\u30c7\u30fc\u30bf\u306f\u7701\u304d\u307e\u3059\u3002<\/p>\n<p>\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 PointSeeder<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u3001\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong>database\/seeders\/PointSeeder.php<\/strong><\/p>\n<pre>&lt;?php\r\n\r\nnamespace Database\\Seeders;\r\n\r\n<strong>use App\\Models\\Point;<\/strong>\r\nuse Illuminate\\Database\\Seeder;\r\n\r\nclass PointSeeder extends Seeder\r\n{\r\n    \/\/ \u7701\u7565\r\n\r\n    <strong>public function run()<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $point_actions = [<\/strong>\r\n<strong>            ['points' =&gt; 300, 'expiration' =&gt; now()-&gt;addDays(7)],<\/strong>\r\n<strong>            ['points' =&gt; 500, 'expiration' =&gt; now()-&gt;addDays(10)],<\/strong>\r\n<strong>            ['points' =&gt; 700, 'expiration' =&gt; null],<\/strong>\r\n<strong>        ];<\/strong>\r\n\r\n<strong>        foreach ($point_actions as $point_action) {<\/strong>\r\n\r\n<strong>            $point = new Point();<\/strong>\r\n<strong>            $point-&gt;user_id = 1; \/\/ \u30c6\u30b9\u30c8\u306a\u306e\u3067\u56fa\u5b9a<\/strong>\r\n<strong>            $point-&gt;points_added = $point_action['points'];<\/strong>\r\n<strong>            $point-&gt;expired_at = $point_action['expiration'];<\/strong>\r\n<strong>            $point-&gt;save();<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u305d\u3057\u3066\u3001\u30e2\u30c7\u30eb\u3067\u3059\u3002<br \/>\n\u30e2\u30c7\u30eb\u306f\u3001\u4eca\u56de\u4f5c\u3063\u305f<code>Point<\/code>\u3068\u3001\u3059\u3067\u306b\u3042\u308b<code>User<\/code>\u30e2\u30c7\u30eb\u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong>app\/Models\/Point.php<\/strong><\/p>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>namespace App\\Models;<\/strong>\r\n\r\n<strong>use Illuminate\\Database\\Eloquent\\Factories\\HasFactory;<\/strong>\r\n<strong>use Illuminate\\Database\\Eloquent\\Model;<\/strong>\r\n\r\n<strong>class Point extends Model<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    use HasFactory;<\/strong>\r\n\r\n<strong>    protected $appends = [<\/strong>\r\n<strong>        'points_left'<\/strong>\r\n<strong>    ];<\/strong>\r\n\r\n<strong>    \/\/ Accessor<\/strong>\r\n<strong>    public function getPointsLeftAttribute() { \/\/ \u6b8b\u308a\u5229\u7528\u53ef\u80fd\u30dd\u30a4\u30f3\u30c8<\/strong>\r\n\r\n<strong>        return intval($this-&gt;points_added) - intval($this-&gt;points_used);<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>    \/\/ Scope<\/strong>\r\n<strong>    public function scopeWhereValid($query, $user_id) {<\/strong>\r\n\r\n<strong>        $query-&gt;where('user_id', $user_id)<\/strong>\r\n<strong>            -&gt;whereColumn('points_added', '!=', 'points_used') \/\/ \u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u6bd4\u8f03<\/strong>\r\n<strong>            -&gt;where(function($query){ \/\/ \u6709\u52b9\u671f\u9650\u5185\u3001\u3082\u3057\u304f\u306f\u6c38\u4e45\u30dd\u30a4\u30f3\u30c8<\/strong>\r\n\r\n<strong>                $query-&gt;whereNull('expired_at')<\/strong>\r\n<strong>                    -&gt;orWhere('expired_at', '&gt;=', now());<\/strong>\r\n\r\n<strong>            })<\/strong>\r\n<strong>            -&gt;orderByRaw('ISNULL(expired_at), expired_at ASC'); \/\/ Null \u306f\u6700\u5f8c\u306b\u4e26\u3079\u308b;<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n<strong>}<\/strong><\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u306f\u300c<strong>\u30b9\u30b3\u30fc\u30d7<\/strong>\u300d\u3092\u4f5c\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u308c\u306f\u5f8c\u307b\u3069\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u90e8\u5206\u3067\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002\u304a\u697d\u3057\u307f\u306b\ud83d\ude0a\u2728<\/p>\n<p><strong>app\/Models\/User.php<\/strong><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\nclass User extends Authenticatable\r\n{\r\n    \/\/ \u7701\u7565\r\n\r\n    <strong>public function getValidPointsAttribute() {<\/strong>\r\n\r\n<strong>        $points = Point::whereValid($this-&gt;id)-&gt;get();<\/strong>\r\n<strong>        $total_points_added = $points-&gt;sum('points_added');<\/strong>\r\n<strong>        $total_points_used = $points-&gt;sum('points_used');<\/strong>\r\n\r\n<strong>        return $total_points_added - $total_points_used;<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u306f\u300c<strong>\u73fe\u5728\u6709\u52b9\u306a\u30dd\u30a4\u30f3\u30c8\uff08\u81ea\u7531\u306b\u4f7f\u3048\u308b\u30dd\u30a4\u30f3\u30c8\uff09<\/strong>\u300d\u3092\u53d6\u5f97\u3059\u308b<code>Accessor<\/code>\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001<code>$user-&gt;valid_points;<\/code>\u3068\u3044\u3046\u30ab\u30f3\u30b8\u3067\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b<code>Seeder<\/code>\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u305f\u3060\u3051\u3067\u306f\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u306e\u3067\u3001<code>Laravel<\/code>\u5074\u3078\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace Database\\Seeders;\r\n\r\nuse Illuminate\\Database\\Seeder;\r\n\r\nclass DatabaseSeeder extends Seeder\r\n{\r\n    \/\/ \u7701\u7565\r\n\r\n    public function run()\r\n    {\r\n        \/\/ \u7701\u7565\r\n\r\n        <strong>$this-&gt;call(PointSeeder::class); \/\/ \ud83d\udc48 \u3053\u3053\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f<\/strong>\r\n    }\r\n}<\/pre>\n<p>\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u518d\u69cb\u7bc9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\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 migrate:fresh --seed<\/strong><\/pre>\n<p>\u203b \u306a\u304a\u3001\u6700\u8fd1\u30b7\u30e7\u30fc\u30c8\u30ab\u30c3\u30c8\u3092\u4f5c\u3063\u305f\u306e\u3067\u79c1\u306e\u74b0\u5883\u3067\u306f\u300c<strong>pam:fs<\/strong>\u300d\u3067\u4e0a\u306e\u30b3\u30de\u30f3\u30c9\u304c\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002\u30b3\u30ec\u4fbf\u5229\u3067\u3059\u3088\ud83c\udf90\u3002\u53c2\u8003\u306f<a href=\"https:\/\/laravel-news.com\/bash-aliases\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089<\/a><\/p>\n<p>\u3059\u308b\u3068\u5b9f\u969b\u306e\u30c6\u30fc\u30d6\u30eb\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9262\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_8.png\" alt=\"\" width=\"384\" height=\"300\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_8.png 384w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_8-300x234.png 300w\" sizes=\"auto, (max-width: 384px) 100vw, 384px\" \/><\/p>\n<h1>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u3053\u3053\u304b\u3089\u306f\u300c<strong>\u30d5\u30a9\u30fc\u30e0\u306b\u4f7f\u7528\u3057\u305f\u3044\u30dd\u30a4\u30f3\u30c8\u3092\u5165\u529b\u3057\u3066\u9001\u4fe1\u3059\u308b<\/strong>\u300d\u3068\u3044\u3046\u90e8\u5206\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\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 PointController<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u30fb\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\n<strong>use App\\Models\\Point;<\/strong>\r\nuse Illuminate\\Http\\Request;\r\n\r\nclass PointController extends Controller\r\n{\r\n    <strong>public function create(Request $request) {<\/strong>\r\n\r\n<strong>        $user = $request-&gt;user();<\/strong>\r\n\r\n<strong>        return view('point.create')-&gt;with([<\/strong>\r\n<strong>            'user' =&gt; $user<\/strong>\r\n<strong>        ]);<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>    public function store(Request $request) {<\/strong>\r\n\r\n<strong>        \/\/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u7701\u7565\u3057\u3066\u3044\u307e\u3059<\/strong>\r\n\r\n<strong>        $user_id = auth()-&gt;id();<\/strong>\r\n<strong>        $using_points = intval($request-&gt;using_points);<\/strong>\r\n<strong>        $valid_points = Point::whereValid($user_id)-&gt;get();<\/strong>\r\n\r\n<strong>        foreach($valid_points as $valid_point) {<\/strong>\r\n\r\n<strong>            if($valid_point-&gt;points_left &lt; $using_points) { \/\/ \u6b8b\u308a\u6709\u52b9\u30dd\u30a4\u30f3\u30c8\u3088\u308a\u5927\u304d\u3044\u5834\u5408<\/strong>\r\n\r\n<strong>                $using_points -= $valid_point-&gt;points_left;<\/strong>\r\n<strong>                $valid_point-&gt;points_used = $valid_point-&gt;points_added;<\/strong>\r\n<strong>                $valid_point-&gt;save();<\/strong>\r\n\r\n<strong>            } else { \/\/ \u6b8b\u308a\u6709\u52b9\u30dd\u30a4\u30f3\u30c8\u306e\u7bc4\u56f2\u5185<\/strong>\r\n\r\n<strong>                $valid_point-&gt;points_used += $using_points;<\/strong>\r\n<strong>                $valid_point-&gt;save();<\/strong>\r\n<strong>                break;<\/strong>\r\n\r\n<strong>            }<\/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\u91cd\u8981\u306a\u306e\u306f\u3001\u30dd\u30a4\u30f3\u30c8\u3092\u4f7f\u7528\u3059\u308b\u300c<strong>\u30c7\u30fc\u30bf\u306e\u4e26\u3073\u9806<\/strong>\u300d\u3067\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u4eca\u56de\u306f\u300c\u6709\u52b9\u671f\u9650\u304c\u3042\u308b\u30dd\u30a4\u30f3\u30c8\u300d\u3092\u6271\u3046\u305f\u3081\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u640d\u3092\u3057\u306a\u3044\u3088\u3046\u3001<strong>\u6709\u52b9\u671f\u9650\u306e\u8fd1\u3044\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8\u304b\u3089\u512a\u5148\u3057\u3066<\/strong>\u6d88\u8cbb\u3057\u3066\u3044\u304b\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002<\/p>\n<p>\u3053\u306e\u305f\u3081\u3001<code>$valid_points<\/code>\u306e\u4e2d\u8eab\u306f\u4eca\u56de\u306e\u30c7\u30fc\u30bf\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<ol>\n<li>\uff17\u65e5\u5f8c\u306b\u671f\u9650\u304c\u6765\u308b\u30dd\u30a4\u30f3\u30c8\uff08\u4e00\u756a\u5148\u306b\u671f\u9650\u304c\u7d42\u308f\u308b\uff09<\/li>\n<li>10\u65e5\u5f8c\u306b\u671f\u9650\u304c\u304f\u308b\u30dd\u30a4\u30f3\u30c8\uff08\u4e8c\u756a\u5148\u306b\u671f\u9650\u304c\u7d42\u308f\u308b\uff09<\/li>\n<li>\u671f\u9650\u306a\u3057\uff08\u3044\u3064\u3067\u3082\u4f7f\u3048\u308b\uff09<\/li>\n<\/ol>\n<p>\u305d\u3057\u3066\u3001\u3053\u308c\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b\u3001\u30e2\u30c7\u30eb<code>Point<\/code>\u306b\u3064\u304f\u3063\u305f\u30b9\u30b3\u30fc\u30d7<code>scopeWhereValid()<\/code> \u5185\u306e\u4ee5\u4e0b\u306e\u90e8\u5206\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>-&gt;orderByRaw('ISNULL(expired_at), expired_at ASC')<\/strong><\/pre>\n<p>\u3053\u308c\u306f\u4f55\u3092\u3057\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u3068\u3001\u901a\u5e38<code>Null<\/code>\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u4e26\u3079\u66ff\u3048\u308b\u3068\u3001<\/p>\n<ol>\n<li>\u5148\u306b Null<\/li>\n<li>\u305d\u308c\u4ee5\u5916\u306f\u305d\u306e\u5f8c<\/li>\n<\/ol>\n<p>\u3068\u3044\u3046\u4e26\u3073\u306b\u306a\u308b\u305f\u3081\u3001\u4eca\u56de\u306e\u30b1\u30fc\u30b9\u3067\u3044\u3046\u3068\u5148\u306b\u6c38\u4e45\u30dd\u30a4\u30f3\u30c8\u3092\u4f7f\u3046\u3053\u3068\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u306f\u30e6\u30fc\u30b6\u30fc\u304c\u300c<strong>\u3044\u3084\u3044\u3084\u3001\u671f\u9650\u4ed8\u304d\u304b\u3089\u4f7f\u3048\u3088\u2026 \ud83d\ude25<\/strong>\u300d\u3068\u306a\u3063\u3066\u3057\u307e\u3046\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u5148\u307b\u3069\u306e<code>ISNULL<\/code>\u3092\u4f7f\u3063\u3066\u3001<\/p>\n<ol>\n<li>\u5148\u306b Null \u4ee5\u5916\u306e\u3082\u306e<\/li>\n<li>Null \u306e\u3082\u306e<\/li>\n<\/ol>\n<p>\u3068\u3044\u3046\u4e26\u3073\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p>\u7d9a\u3044\u3066\u30d3\u30e5\u30fc\uff08HTML\u90e8\u5206\uff09\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<p><strong>resources\/views\/point\/create.blade.php<\/strong><\/p>\n<pre><strong>&lt;html&gt;<\/strong>\r\n<strong>&lt;head&gt;<\/strong>\r\n<strong>    &lt;link href=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.0.1\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;<\/strong>\r\n<strong>&lt;\/head&gt;<\/strong>\r\n<strong>&lt;body&gt;<\/strong>\r\n<strong>&lt;div id=\"app\" class=\"p-4\"&gt;<\/strong>\r\n<strong>    &lt;div class=\"card\" style=\"width:18rem;\"&gt;<\/strong>\r\n<strong>        &lt;div class=\"card-body\"&gt;<\/strong>\r\n<strong>            &lt;h5 class=\"card-title\"&gt;\u30dd\u30a4\u30f3\u30c8\u3092\u4f7f\u7528\u3059\u308b&lt;\/h5&gt;<\/strong>\r\n<strong>            &lt;p class=\"card-text\"&gt;\u73fe\u5728\u6709\u52b9\u306a\u30dd\u30a4\u30f3\u30c8\u306f\u3001&lt;strong&gt;{{ $user-&gt;valid_points }}\u30dd\u30a4\u30f3\u30c8&lt;\/strong&gt;\u3067\u3059\u3002&lt;\/p&gt;<\/strong>\r\n<strong>            &lt;div class=\"input-group mb-3\"&gt;<\/strong>\r\n<strong>                &lt;input type=\"number\" class=\"form-control\" min=\"1\" max=\"{{ $user-&gt;valid_points }}\" v-model=\"usingPoints\"&gt;<\/strong>\r\n<strong>                &lt;span class=\"input-group-text\"&gt;P&lt;\/span&gt;<\/strong>\r\n<strong>            &lt;\/div&gt;<\/strong>\r\n<strong>            &lt;div class=\"text-end\"&gt;<\/strong>\r\n<strong>                &lt;button type=\"button\" class=\"btn btn-outline-primary\" @click=\"onSubmit\"&gt;\u9001\u4fe1\u3059\u308b&lt;\/button&gt;<\/strong>\r\n<strong>            &lt;\/div&gt;<\/strong>\r\n<strong>        &lt;\/div&gt;<\/strong>\r\n<strong>    &lt;\/div&gt;<\/strong>\r\n<strong>&lt;\/div&gt;<\/strong>\r\n<strong>&lt;script src=\"https:\/\/unpkg.com\/vue@3.0.11\/dist\/vue.global.prod.js\"&gt;&lt;\/script&gt;<\/strong>\r\n<strong>&lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/axios\/0.21.1\/axios.min.js\"&gt;&lt;\/script&gt;<\/strong>\r\n<strong>&lt;script&gt;<\/strong>\r\n\r\n<strong>    Vue.createApp({<\/strong>\r\n<strong>        data() {<\/strong>\r\n<strong>            return {<\/strong>\r\n<strong>                usingPoints: ''<\/strong>\r\n<strong>            }<\/strong>\r\n<strong>        },<\/strong>\r\n<strong>        methods: {<\/strong>\r\n<strong>            onSubmit() {<\/strong>\r\n\r\n<strong>                const url = '{{ route('point.store') }}';<\/strong>\r\n<strong>                const params = {<\/strong>\r\n<strong>                    using_points: this.usingPoints<\/strong>\r\n<strong>                };<\/strong>\r\n<strong>                axios.post(url, params)<\/strong>\r\n<strong>                    .then(response =&gt; {<\/strong>\r\n\r\n<strong>                        if(response.data.result === true) {<\/strong>\r\n\r\n<strong>                            location.reload();<\/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>                        \/\/ \u3053\u3053\u3067\u30a8\u30e9\u30fc\u51e6\u7406<\/strong>\r\n\r\n<strong>                    });<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n<strong>        }<\/strong>\r\n<strong>    }).mount('#app');<\/strong>\r\n\r\n<strong>&lt;\/script&gt;<\/strong>\r\n<strong>&lt;\/body&gt;<\/strong>\r\n<strong>&lt;\/html&gt;<\/strong><\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6709\u52b9\u306a\u30dd\u30a4\u30f3\u30c8\u3092\u8868\u793a\u3057\u3001\u4f7f\u7528\u3057\u305f\u3044\u30dd\u30a4\u30f3\u30c8\u3092\u5165\u529b\u3057\u3066\u9001\u4fe1\u3059\u308b\u30d5\u30a9\u30fc\u30e0\u3092\u3064\u304f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9258\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_5.png\" alt=\"\" width=\"317\" height=\"251\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_5.png 317w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_5-300x238.png 300w\" sizes=\"auto, (max-width: 317px) 100vw, 317px\" \/><\/p>\n<p>\u203b <code>Bootstrap 5<\/code>\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002\u300c<strong>text-right<\/strong>\u300d\u304c\u300c<strong>text-end<\/strong>\u300d\u306b\u5909\u308f\u3063\u3066\u3044\u3066\u3061\u3087\u3063\u3068\u6238\u60d1\u3044\u307e\u3057\u305f\uff08\u7b11\uff09<\/p>\n<h1>\u30eb\u30fc\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u6700\u5f8c\u306b\u30eb\u30fc\u30c8\u3092\u30bb\u30c3\u30c8\u3057\u3066\u30dd\u30a4\u30f3\u30c8\u7528\u306eURL\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>use App\\Http\\Controllers\\PointController;<\/strong>\r\n\r\n<strong>\/\/ \u7701\u7565<\/strong>\r\n\r\n<strong>Route::prefix('point')-&gt;middleware('auth')-&gt;group(function(){<\/strong>\r\n\r\n<strong>    Route::get('create', [PointController::class, 'create'])-&gt;name('point.create');<\/strong>\r\n<strong>    Route::post('\/', [PointController::class, 'store'])-&gt;name('point.store');<\/strong>\r\n\r\n<strong>});<\/strong><\/pre>\n<p>\u306a\u304a\u3001\u4eca\u56de\u306e\u30b3\u30fc\u30c9\u306f<strong>\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0<\/strong>\u3068\u3057\u3066\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001\u30df\u30c9\u30eb\u30a6\u30a7\u30a2<code>auth<\/code>\u3092\u3064\u3051\u307e\u3057\u305f\u3002<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<\/p>\n<p>\u307e\u305a\u306f\u4f5c\u696d\u306b\u5165\u308b\u524d\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u78ba\u8a8d\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9259\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_4.png\" alt=\"\" width=\"557\" height=\"326\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_4.png 557w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_4-300x176.png 300w\" sizes=\"auto, (max-width: 557px) 100vw, 557px\" \/><\/p>\n<p>\u30dd\u30a4\u30f3\u30c8\u306f\u5168\u304f\u4f7f\u7528\u3055\u308c\u3066\u304a\u3089\u305a\u3001\u73fe\u5728\u5408\u8a08<code>1,500<\/code>\u30dd\u30a4\u30f3\u30c8\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u30ed\u30b0\u30a4\u30f3\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9261\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_2.png\" alt=\"\" width=\"479\" height=\"297\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_2.png 479w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_2-300x186.png 300w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/p>\n<p>\u305d\u3057\u3066\u300c<strong>http:\/\/*******\/point\/create<\/strong>\u300d\u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3059\u308b\u3068\u3001\u30d5\u30a9\u30fc\u30e0\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u4f8b\u306e\u30b9\u30c8\u30fc\u30ea\u30fc\u3069\u304a\u308a<code>500<\/code>\u3092\u5165\u529b\u3057\u3066\u9001\u4fe1\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9260\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_3.png\" alt=\"\" width=\"317\" height=\"251\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_3.png 317w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_3-300x238.png 300w\" sizes=\"auto, (max-width: 317px) 100vw, 317px\" \/><\/p>\n<p>\u3059\u308b\u3068\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9258\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_5.png\" alt=\"\" width=\"317\" height=\"251\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_5.png 317w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_5-300x238.png 300w\" sizes=\"auto, (max-width: 317px) 100vw, 317px\" \/><\/p>\n<p>\u30da\u30fc\u30b8\u304c\u30ea\u30ed\u30fc\u30c9\u3055\u308c\u3066\u8868\u793a\u304c\u5909\u308f\u308a\u307e\u3057\u305f\u3002<br \/>\n<code>1,500 - 500<\/code> \u306a\u306e\u3067\u3053\u306e\u8868\u793a\u3067\u6b63\u3057\u3044\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<p>\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306f\u3069\u3046\u306a\u3063\u3066\u3044\u308b\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9257\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_6.png\" alt=\"\" width=\"555\" height=\"323\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_6.png 555w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_6-300x175.png 300w\" sizes=\"auto, (max-width: 555px) 100vw, 555px\" \/><\/p>\n<p>\u306f\u3044\u2757<\/p>\n<p><code>300 + 200 = 500<\/code> \u30dd\u30a4\u30f3\u30c8\u304c\u4f7f\u7528\u3055\u308c\u305f\u3053\u3068\u306b\u306a\u3063\u3066\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001\u3053\u3053\u3067\u91cd\u8981\u306a\u306e\u304c\u300c<strong>\u9806\u756a<\/strong>\u300d\u3067\u3059\u3002<\/p>\n<p>\u4f55\u5ea6\u3082\u8a00\u3044\u307e\u3059\u304c\u3001<strong>\u6709\u52b9\u671f\u9650\u304c\u8fd1\u3044\u3082\u306e\u304b\u3089\u30dd\u30a4\u30f3\u30c8\u3092\u4f7f\u308f\u306a\u3044\u3068\u3044\u3051\u306a\u3044<\/strong>\u306e\u3067\u3001<code>expired_at<\/code>\u304c\u300c\u82e5\u3044\u300d\u9806\u306b\u30dd\u30a4\u30f3\u30c8\u3092\u6d88\u8cbb\u3057\u3066\u3044\u304b\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u4e0a\u306e\u753b\u50cf\u3067\u5408\u3063\u3066\u3044\u307e\u3059\u306d\ud83d\udc4d<\/p>\n<p>\u3067\u306f\u3001\u6700\u5f8c\u306b\u300c<strong>15\u65e5\u7d4c\u904e\u3057\u305f\u5f8c<\/strong>\u300d\u306b\u73fe\u5728\u306e<code>1,000<\/code>\u30dd\u30a4\u30f3\u30c8\u304c\u3069\u3046\u306a\u3063\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u30fb\u30fb\u30fb\u3068\u306f\u3044\u3048\uff12\u9031\u9593\u4ee5\u4e0a\u5f85\u3063\u3066\u3044\u3089\u308c\u306a\u3044\u306e\u3067\u3001\u300c<strong>\u3042\u308b\u30c6\u30af\u30cb\u30c3\u30af<\/strong>\u300d\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u306f\u65e5\u4ed8\u30d1\u30c3\u30b1\u30fc\u30b8<code>Carbon<\/code>\u306b\u306f\u300c<strong>\u3042\u305f\u304b\u3082\u4eca\u304c\u3001\u25cf\u5e74\u25cf\u6708\u25cf\u65e5\u3067\u3042\u308b<\/strong>\u300d\u304b\u306e\u3088\u3046\u306b\u65e5\u4ed8\u3092\u30bb\u30c3\u30c8\u3059\u308b\u6a5f\u80fd\u304c\u3042\u308b\u3093\u3067\u3059\u306d\u3002\u3053\u308c\u306f\u30c6\u30b9\u30c8\u5411\u3051\u306b\u7528\u610f\u3057\u3066\u304f\u308c\u3066\u3044\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u3084\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>app\/Providers\/AppServiceProvider.php<\/strong><\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Providers;\r\n\r\n<strong>use Carbon\\Carbon;<\/strong>\r\nuse Illuminate\\Support\\ServiceProvider;\r\n\r\nclass AppServiceProvider extends ServiceProvider\r\n{\r\n    \/\/ \u7701\u7565\r\n\r\n    public function boot()\r\n    {\r\n        <strong>\/\/ 15\u65e5\u5f8c\u306b\u79fb\u52d5\u300c\u3057\u305f\u3082\u306e\u3068\u3057\u3066\u300d\u5b9f\u884c<\/strong>\r\n<strong>        $target_dt = today()-&gt;addDays(15);<\/strong>\r\n<strong>        Carbon::setTestNow($target_dt);<\/strong>\r\n    }\r\n}<\/pre>\n<p>\u4eca\u56de\u306f\u3001<code>Laravel<\/code>\u5168\u3066\u306b\u5f71\u97ff\u3059\u308b\u3088\u3046\u306b<code>AppServiceProvider<\/code>\u306b\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u5b9f\u884c\u3057\u305f\u3044\u5834\u6240\u306e\u76f4\u524d\u306b\u66f8\u304f\u3060\u3051\u3067\u3082\u6709\u52b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u3053\u308c\u3067\u5148\u307b\u3069\u306e<code>1,000<\/code>\u30dd\u30a4\u30f3\u30c8\u304c\u3069\u3046\u306a\u308b\u304b\u3001\u30ea\u30ed\u30fc\u30c9\u3057\u3066\u307f\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9256\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_7.png\" alt=\"\" width=\"314\" height=\"247\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_7.png 314w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/06\/laravel_expiration_points_7-300x236.png 300w\" sizes=\"auto, (max-width: 314px) 100vw, 314px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u60f3\u5b9a\u901a\u308a<code>700<\/code>\u30dd\u30a4\u30f3\u30c8\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u6709\u52b9\u671f\u9650\u304c\u8feb\u3063\u3066\u3044\u305f<code>300<\/code>\u30dd\u30a4\u30f3\u30c8\u304c\u6d88\u6ec5\u3057\u3066\u3057\u307e\u3063\u305f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5168\u3066\u6210\u529f\u3067\u3059\u2728\ud83d\ude0a\ud83d\udc4d<\/p>\n<h1>\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h1>\n<p>\u4eca\u56de\u306e\u6a5f\u80fd\u3092\u4f7f\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u300c\u3082\u3046\u5c11\u3057\u3067\u30dd\u30a4\u30f3\u30c8\u304c\u306a\u304f\u306a\u3063\u3061\u3083\u3046\u304b\u3089\u304a\u91d1\u8db3\u3057\u3066\u3067\u3082\u4f55\u304b\u8cb7\u304a\u3046\u300d\u3068\u3044\u3046\u30a4\u30f3\u30bb\u30f3\u30c6\u30a3\u30d6\u306b\u306a\u308b\u3002<\/li>\n<li>\u300c\u3082\u3046\u3059\u3050\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8\u304c\u306a\u304f\u306a\u308a\u307e\u3059\u300d\u901a\u77e5\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u3068\u3001\u5b9f\u8cea\u306f\u8ca9\u4fc3\u306b\u306a\u308b\u4e0a\u306b\u3001\u300c\u91cd\u8981\u306a\u30e1\u30fc\u30eb\u300d\u3068\u3057\u3066\u9001\u4fe1\u3057\u3084\u3059\u3044\u3002<\/li>\n<li>\uff08\u5b63\u7bc0\u306a\u3069\u306e\uff09\u30ad\u30e3\u30f3\u30da\u30fc\u30f3\u3068\u7d61\u3081\u3066\u30dd\u30a4\u30f3\u30c8\u4ed8\u4e0e\u3057\u3084\u3059\u3044\u3002<\/li>\n<li>\u5b9f\u969b\u306b\u306f\u4f7f\u308f\u308c\u306a\u3044\u30dd\u30a4\u30f3\u30c8\u3082\u767a\u751f\u3059\u308b\u306e\u3067\u3001\u300c\u7dcf\u984d\u25cf\u25cf\u25cf\u25cf\u5186\u5206\u306e\u30dd\u30a4\u30f3\u30c8\u3092\u30d7\u30ec\u30bc\u30f3\u30c8\uff01\u300d\u3068\u9298\u6253\u3063\u3066\u3044\u3066\u3082\u3001\u305d\u308c\u3088\u308a\u3082\u8cbb\u7528\u306f\u5c11\u306a\u304f\u6e08\u3080\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3002<\/li>\n<li>\u9006\u306b\u300c\u6c38\u4e45\u30dd\u30a4\u30f3\u30c8\u300d\u306e\u4fa1\u5024\u304c\u9ad8\u307e\u308b\u305f\u3081\u3001\u3053\u3053\u305e\u3068\u3044\u3046\u3068\u304d\u306e\u305f\u3081\u306b\u6c38\u4e45\u30dd\u30a4\u30f3\u30c8\u306e\u4ed8\u4e0e\u3092\u6d3b\u7528\u3067\u304d\u308b<\/li>\n<\/ul>\n<p>\u3082\u3057\u3053\u3046\u3044\u3063\u305f\u6a5f\u80fd\u3092\u3054\u5e0c\u671b\u3067\u3057\u305f\u3089\u3001\u3044\u3064\u3067\u3082\u304a\u554f\u3044\u5408\u308f\u305b\u304b\u3089\u304a\u6c17\u8efd\u306b\u3054\u76f8\u8ac7\u304f\u3060\u3055\u3044\u3002\u3069\u3046\u305e\u3088\u308d\u3057\u304f\u304a\u9858\u3044\u3044\u305f\u3057\u307e\u3059\u3002m(_ _)m<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>Laravel<\/code>\u3067\u300c<strong>\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8<\/strong>\u300d\u6a5f\u80fd\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u306f\u4eca\u56de\u306e\u30a2\u30a4\u30c7\u30a2\u306f\u3001\u30ed\u30b1\u30c3\u30c8\u30cb\u30e5\u30fc\u30b9\u3055\u3093\u306e\u8a18\u4e8b\u3092\u8aad\u3093\u3060\u3068\u304d\u306b\u601d\u3044\u3064\u304d\u307e\u3057\u305f\u3002<\/p>\n<p><strong>\ud83d\udcdd \u53c2\u8003\u30da\u30fc\u30b8\uff1a<\/strong> <a href=\"https:\/\/rocketnews24.com\/2021\/06\/06\/1499980\/\" target=\"_blank\" rel=\"noopener\">\u3010\u6ce8\u610f\u559a\u8d77\u3011Gmail\u306e\u30e1\u30fc\u30eb\u81ea\u52d5\u632f\u308a\u5206\u3051\u6a5f\u80fd\u30677000\u5186\u306e\u5927\u640d\u3092\u3057\u305f\u5b9f\u8a71 \/ \u3044\u3064\u306e\u307e\u306b\u304b\u5b58\u5728\u3059\u308b\u300c\u30d7\u30ed\u30e2\u30fc\u30b7\u30e7\u30f3\u300d\u30bf\u30d6\u306b\u3054\u6ce8\u610f\uff01<\/a><\/p>\n<p>\u3053\u306e\u30da\u30fc\u30b8\u3092\u898b\u305f\u3068\u304d\u3001<\/p>\n<ol>\n<li>\u305d\u3046\u3044\u3048\u3070\u3001\u697d\u5929\u30dd\u30a4\u30f3\u30c8\u3092\u5c71\u307b\u3069\u5931\u3063\u3066\u3057\u307e\u3063\u305f\u3053\u3068\u3042\u308b\u306a&#8230;<\/li>\n<li>\u3042\u308c\u3063\u3066\u3044\u3064\u307e\u3067\u3082\u4f7f\u3048\u306a\u3044\u30dd\u30a4\u30f3\u30c8\u304c\u3042\u308b\u3093\u3060\u3063\u305f\u3063\u3051&#8230;&#8230;<\/li>\n<li>\u305d\u3063\u304b\u3001\u671f\u9593\u9650\u5b9a\u30dd\u30a4\u30f3\u30c8\u6a5f\u80fd\u3060\uff01<\/li>\n<\/ol>\n<p>\u3068\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u4f55\u6c17\u306a\u304f\u898b\u3066\u305f\u3060\u3051\u3060\u3063\u305f\u3093\u3067\u3059\u3051\u3069\u3001\u3053\u3046\u3044\u3046\u3053\u3068\u3063\u3066\u7d50\u69cb\u3042\u308b\u306e\u3067\u3001\u3053\u308c\u304b\u3089\u3082\u3044\u308d\u3044\u308d\u3068\u8208\u5473\u3092\u6301\u3063\u3066\u3044\u304d\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u30c1\u30e3\u30ec\u30f3\u30b8\u3057\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-9056 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/04\/no_46.png\" alt=\"\" width=\"340\" height=\"350\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/04\/no_46.png 340w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/04\/no_46-291x300.png 291w\" sizes=\"auto, (max-width: 340px) 100vw, 340px\" \/>\u300c\u30dd\u30a4\u30f3\u30c8\u306f\u8caf\u3081\u305a\u306b\u3001<br \/>\n\u5168\u90e8\u4f7f\u3046\u30bf\u30a4\u30d7\u3067\u3059\ud83d\udc4d\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u308c\u306f\u500b\u4eba\u7684\u306a\u8a71\u306a\u306e\u3067\u3059\u304c\u3001\u304a\u8cb7\u3044\u7269\u306e\u3068\u304d\u300c\u30dd\u30a4\u30f3\u30c8\u30ab\u30fc\u30c9\u3064\u304f\u308a\u307e\u3059\u304b\u2753\u300d\u3068\u805e\u304b\u308c\u3066\u3082\u3001\u300c\u30dd\u30a4\u30f3\u30c8\u304c\u3042\u308b\u3053\u3068\u3067\u5224\u65ad\u304c\u920d\u308b\u5834\u5408\u300d\u306f\u65ad\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=9251\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel \u3067\u300c\u6709\u52b9\u671f\u9650\u3064\u304d\u300d\u30dd\u30a4\u30f3\u30c8\u30b7\u30b9\u30c6\u30e0\u3092\u3064\u304f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":9266,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[236],"class_list":["post-9251","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-236"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9251","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=9251"}],"version-history":[{"count":8,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9251\/revisions"}],"predecessor-version":[{"id":9268,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9251\/revisions\/9268"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/9266"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}