{"id":12733,"date":"2024-06-16T07:00:04","date_gmt":"2024-06-15T22:00:04","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=12733"},"modified":"2024-06-05T06:09:10","modified_gmt":"2024-06-04T21:09:10","slug":"laravel%ef%bc%9a%e6%a8%a9%e5%a8%81%e6%80%a7%e3%81%8c%e3%81%82%e3%82%8b%e3%83%84%e3%82%a4%e3%83%bc%e3%83%88%e3%82%92%e8%87%aa%e5%8b%95%e6%8a%95%e7%a8%bf%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=12733","title":{"rendered":"Laravel\uff1a\u6a29\u5a01\u6027\u304c\u3042\u308b\u30c4\u30a4\u30fc\u30c8\u3092\u81ea\u52d5\u6295\u7a3f\u3059\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u79c1\u306f\u500b\u4eba\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u300c<strong><a href=\"https:\/\/www.prerele.com\/\" target=\"_blank\" rel=\"noopener\">\u3077\u308c\u308a\u308a<\/a><\/strong>\u300d\u3068\u3044\u3046\u540d\u524d\u306e\u300c<strong>\u7121\u6599\u3067\u4f7f\u3048\u308b\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9<\/strong>\u300d\u30b9\u30bf\u30f3\u30c9\u3092\u904b\u55b6\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307b\u307c\u30dc\u30e9\u30f3\u30c6\u30a3\u30a2\u3067\u904b\u55b6\u3057\u3066\u308b\u3093\u3067\u3059\u304c <code>2024.5.18<\/code>\u73fe\u5728\u3067<code>40,000<\/code>\u4ef6\u4ee5\u4e0a\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u304c\u6295\u7a3f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u308c\u306f\u6700\u8fd1\u52c9\u5f37\u3057\u3066\u308b\u30de\u30fc\u30b1\u30c6\u30a3\u30f3\u30b0\u3067\u8a00\u3046\u3068\u300c<strong>\u6a29\u5a01\u6027\u304c\u3042\u308b<\/strong>\u300d\u72b6\u614b\u3067\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u300c<strong>\u305d\u3093\u306a\u3044\u3063\u3071\u3044\u6295\u7a3f\u3055\u308c\u3066\u308b\u3063\u3066\u3053\u3068\u306f\u826f\u3044\u30b5\u30a4\u30c8\u306a\u3093\u3058\u3083\u306a\u3044\uff01\uff1f<\/strong>\u300d\u3063\u3066\u306a\u308b\u932f\u899a\u3059\u308b\u308f\u3051\u3067\u3059\u306d\uff08\u5b9f\u969b\u826f\u3044\u30b5\u30a4\u30c8\u3060\u3068\u601d\u3063\u3066\u307e\u3059\u304c\u2026\uff09<\/p>\n<p>\u305d\u3046\u8003\u3048\u3066\u305f\u3089\u3001\u3042\u308b\u958b\u767a\u30a2\u30a4\u30c7\u30a2\u304c\u6d6e\u304b\u3093\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u306f\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u6295\u7a3f\u6570\u304c\u5927\u53f0\u306b\u4e57\u308b\u305f\u3073\u306b\u81ea\u52d5\u3067\u30c4\u30a4\u30fc\u30c8\u3092\u3059\u308b<\/strong><\/p>\n<p>\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u6b21\u306f\u300c<strong>41,000\u4ef6\u7a81\u7834\u3057\u307e\u3057\u305f\uff01<\/strong>\u300d\u3068\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306d\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u3082<code>Laravel<\/code>\u3092\u4f7f\u3063\u3066\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u203b\u3061\u306a\u307f\u306b\u6a29\u5a01\u6027\u306e\u3042\u308b\u30c4\u30a4\u30fc\u30c8\u306f\u65b0\u898f\u30d5\u30a9\u30ed\u30ef\u30fc\u306b\u3064\u306a\u304c\u308a\u3084\u3059\u3044\u306e\u3067\u30a2\u30ab\u30a6\u30f3\u30c8\u958b\u8a2d\u3057\u305f\u76f4\u5f8c\u306f\u3088\u308a\u591a\u3081\u3067\u6295\u7a3f\u3059\u308b\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\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-3566 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1.png\" alt=\"\" width=\"306\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1.png 306w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1-287x300.png 287w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/>\u300c\u30d3\u30fc\u30eb\u91b8\u9020\u6240\u3067\u6559\u3048\u3066\u3082\u3089\u3063\u305f<br \/>\n\u30de\u30fc\u30b1\u672c\u3001\u52c9\u5f37\u306b\u306a\u308a\u307e\u3057\u305f\u2757\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 11.x<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u73fe\u72b6\u3067<code>40,000<\/code>\u4ef6\u3092\u8d85\u3048\u3066\u3044\u308b\u306e\u3067\u3001\u5b9f\u969b\u306e\u904b\u7528\u3067\u306f<code>1,000<\/code>\u4ef6\u3054\u3068\u306b\u81ea\u52d5\u3067\u30c4\u30a4\u30fc\u30c8\u3067\u304d\u308b\u3088\u3046\u3057\u3088\u3046\u3068\u8003\u3048\u3066\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u3082\u3001<code>1000<\/code>\u3067\u56fa\u5b9a\u3060\u3068\u5225\u306e\u65b0\u898f\u30b5\u30a4\u30c8\u3092\u4f5c\u3063\u305f\u3089\u9060\u3059\u304e\u308b\u9053\u306e\u308a\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u74b0\u5883\u5909\u6570\u3067\u3053\u306e\u6570\u5b57\u306f\u81ea\u7531\u306b\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u4eca\u56de\u306f<code>100<\/code>\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><strong>.env<\/strong><\/p>\n<div>\n<pre><strong>RELEASE_COUNT_NEAREST_NUMBER=100<\/strong><\/pre>\n<\/div>\n<h1>\u524d\u63d0\u3068\u3057\u3066<\/h1>\n<p>\u4eca\u56de\u3082\u3059\u3067\u306b<code>Twitter API<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306e\u4ee5\u4e0b\uff14\u3064\u306e\u30ad\u30fc\u3092\u53d6\u5f97\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u524d\u63d0\u3067\u3059\u3002<\/p>\n<ul>\n<li>CONSUMER KEY\uff08API Key)<\/li>\n<li>CONSUMER SECRET \uff08API Secret\uff09<\/li>\n<li>ACCESS TOKEN\uff08Access Token\uff09<\/li>\n<li>ACCESS SECRET\uff08Access Secret\uff09<\/li>\n<\/ul>\n<p>\u306a\u304a\u3001<code>API<\/code>\u306e\u767b\u9332\u3084\u30ad\u30fc\u306e\u53d6\u5f97\u306f\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u304c\u308f\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<p><strong>\ud83d\udcdd\u00a0<a href=\"https:\/\/zenn.dev\/eito_blog\/articles\/a982fdb073493a\" target=\"_blank\" rel=\"noopener\">\u30102023\u5e74\u5ea6\u6700\u65b0\u7248\u3011Twitter API \u53d6\u5f97\u65b9\u6cd5<\/a><\/strong><\/p>\n<p>\u305d\u3057\u3066\u3001\uff14\u3064\u306e\u30ad\u30fc\u3092\u53d6\u5f97\u3057\u305f\u3089\u3001<code>.env<\/code>\u306b\u30bb\u30c3\u30c8\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>.env<\/strong><\/p>\n<div>\n<pre><strong>TWITTER_CONSUMER_KEY=\"\uff08\u3053\u3053\u306bAPI Key\uff09\"<\/strong>\r\n<strong>TWITTER_CONSUMER_SECRET=\"\uff08\u3053\u3053\u306bAPI Key Secret\uff09\"<\/strong>\r\n<strong>TWITTER_ACCESS_TOKEN=\"\uff08\u3053\u3053\u306bAccess Token\uff09\"<\/strong>\r\n<strong>TWITTER_ACCESS_TOKEN_SECRET=\"\uff08\u3053\u3053\u306bAccess Token Secret\uff09\"<\/strong><\/pre>\n<h1>\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p>\u6b21\u306b\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n<div>\n<pre><strong>composer require abraham\/twitteroauth<\/strong><\/pre>\n<p>\u3053\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306f<code>Laravel<\/code>\u3067\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u306a\u3089\u5fc5\u9808\u3067\u3059\u306d\uff01\u611f\u8b1d\u266a<\/p>\n<\/div>\n<\/div>\n<h1>DB\u5468\u308a\u3092\u3064\u304f\u308b<\/h1>\n<p>\u5b9f\u969b\u306e\u30b5\u30a4\u30c8\u3067\u306f\u5c11\u3057<code>DB<\/code>\u69cb\u6210\u304c\u9055\u3044\u307e\u3059\u304c\u3001<code>releases<\/code>\u3068\u3044\u3046\u30c6\u30fc\u30d6\u30eb\u3067\u5b9f\u88c5\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n<div>\n<pre><strong>php artisan make:model Release -ms<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u30d5\u30a1\u30a4\u30eb\u304c\uff13\u3064\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u305d\u308c\u305e\u308c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><strong>app\/Models\/Release.php<\/strong><\/p>\n<div>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>namespace App\\Models;<\/strong>\r\n\r\n<strong>use App\\Events\\ReleaseCreated;<\/strong>\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 Release extends Model<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    use HasFactory;<\/strong>\r\n\r\n<strong>    protected $fillable = [<\/strong>\r\n<strong>        'body',<\/strong>\r\n<strong>    ];<\/strong>\r\n\r\n<strong>    \/\/ \u3042\u3068\u3067\u3053\u3053\u306b\u30a4\u30d9\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/strong>\r\n<strong>}<\/strong><\/pre>\n<\/div>\n<\/div>\n<p><strong>database\/migrations\/****_**_**_******_create_releases_table.php<\/strong><\/p>\n<div>\n<pre>&lt;?php\r\n\r\nuse Illuminate\\Database\\Migrations\\Migration;\r\nuse Illuminate\\Database\\Schema\\Blueprint;\r\nuse Illuminate\\Support\\Facades\\Schema;\r\n\r\nreturn new class extends Migration\r\n{\r\n    \/**\r\n     * Run the migrations.\r\n     *\/\r\n    public function up(): void\r\n    {\r\n        <strong>Schema::create('releases', function (Blueprint $table) {<\/strong>\r\n<strong>            $table-&gt;id();<\/strong>\r\n<strong>            $table-&gt;text('body')-&gt;comment('\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u672c\u6587');<\/strong>\r\n<strong>            $table-&gt;timestamps();<\/strong>\r\n<strong>        });<\/strong>\r\n    }\r\n\r\n    \/**\r\n     * Reverse the migrations.\r\n     *\/\r\n    public function down(): void\r\n    {\r\n        Schema::dropIfExists('releases');\r\n    }\r\n};\r\n\r\n<\/pre>\n<\/div>\n<p><strong>database\/seeders\/ReleaseSeeder.php<\/strong><\/p>\n<div>\n<pre>&lt;?php\r\n\r\nnamespace Database\\Seeders;\r\n\r\nuse App\\Models\\Release;\r\nuse Illuminate\\Database\\Console\\Seeds\\WithoutModelEvents;\r\nuse Illuminate\\Database\\Seeder;\r\n\r\nclass ReleaseSeeder extends Seeder\r\n{\r\n    \/**\r\n     * Run the database seeds.\r\n     *\/\r\n    public function run(): void\r\n    {\r\n        <strong>for($i = 0; $i &lt; 98; $i++) {<\/strong>\r\n\r\n<strong>            $release = new Release();<\/strong>\r\n<strong>            $release-&gt;body = '\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u672c\u6587 \u305d\u306e' . $i;<\/strong>\r\n<strong>            $release-&gt;save();<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    }\r\n}<\/pre>\n<\/div>\n<p>\u3067\u306f\u3001<code>Seeder<\/code>\u3092<code>DatabaseSeeder.php<\/code>\u306b\u30bb\u30c3\u30c8\u3057\u3066\u6709\u52b9\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><strong>database\/seeders\/DatabaseSeeder.php<\/strong><\/p>\n<div>\n<pre>&lt;?php\r\n\r\nnamespace Database\\Seeders;\r\n\r\nuse App\\Models\\User;\r\n\/\/ use Illuminate\\Database\\Console\\Seeds\\WithoutModelEvents;\r\nuse Illuminate\\Database\\Seeder;\r\n\r\nclass DatabaseSeeder extends Seeder\r\n{\r\n    \/**\r\n     * Seed the application's database.\r\n     *\/\r\n    public function run(): void\r\n    {\r\n        <strong>$this-&gt;call([<\/strong>\r\n<strong>            ReleaseSeeder::class,<\/strong>\r\n<strong>        ]);<\/strong>\r\n    }\r\n}\r\n\r\n<\/pre>\n<\/div>\n<p>\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u521d\u671f\u5316\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n<div>\n<div>\n<pre><strong>php artisan migrate:fresh --seed<\/strong><\/pre>\n<\/div>\n<\/div>\n<p>\u3059\u308b\u3068\u3001\u5b9f\u969b\u306e\u30c6\u30fc\u30d6\u30eb\u306f\u3053\u3046\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12736\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/05\/laravel_achievement_tweet_3.png\" alt=\"\" width=\"552\" height=\"356\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/05\/laravel_achievement_tweet_3.png 552w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/05\/laravel_achievement_tweet_3-300x193.png 300w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/p>\n<h1>\u30a4\u30d9\u30f3\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001<code>Release<\/code>\u30e2\u30c7\u30eb\u3092\u4f7f\u3063\u3066\u300c<strong>\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u304c\u8ffd\u52a0\u3055\u308c\u305f\u3089\u5fc5\u305a\u5b9f\u884c\u3055\u308c\u308b<\/strong>\u300d\u30a4\u30d9\u30f3\u30c8\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n<div>\n<pre><strong>php artisan make:event ReleaseCreated<\/strong><\/pre>\n<\/div>\n<div>\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\u3057\u307e\u3059\u3002<\/p>\n<\/div>\n<div>\n<pre>&lt;?php\r\n\r\nnamespace App\\Events;\r\n\r\n<strong>use App\\Models\\Release;<\/strong>\r\nuse Illuminate\\Broadcasting\\Channel;\r\nuse Illuminate\\Broadcasting\\InteractsWithSockets;\r\nuse Illuminate\\Broadcasting\\PresenceChannel;\r\nuse Illuminate\\Broadcasting\\PrivateChannel;\r\nuse Illuminate\\Contracts\\Broadcasting\\ShouldBroadcast;\r\nuse Illuminate\\Foundation\\Events\\Dispatchable;\r\nuse Illuminate\\Queue\\SerializesModels;\r\n<strong>use Abraham\\TwitterOAuth\\TwitterOAuth;<\/strong>\r\n\r\nclass ReleaseCreated\r\n{\r\n    use Dispatchable, InteractsWithSockets, SerializesModels;\r\n\r\n    \/**\r\n     * Create a new event instance.\r\n     *\/\r\n    <strong>public function __construct()<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $this-&gt;tweet();<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    private function tweet()<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $cache_key = 'release_count';<\/strong>\r\n<strong>        $prev_nearest_count = (int) cache()-&gt;get($cache_key, 0); \/\/ \u524d\u56de\u306e\u30ea\u30ea\u30fc\u30b9\u6570<\/strong>\r\n<strong>        $nearest_number = (int) env('RELEASE_COUNT_NEAREST_NUMBER', 100);<\/strong>\r\n\r\n<strong>        $release_count = Release::count(); \/\/ \u73fe\u5728\u306e\u30ea\u30ea\u30fc\u30b9\u6570<\/strong>\r\n<strong>        $current_nearest_count = $this-&gt;getNearestCount($release_count, $nearest_number);<\/strong>\r\n\r\n<strong>        if ($prev_nearest_count &lt; $current_nearest_count) { \/\/ \u524d\u56de\u306e\u30ea\u30ea\u30fc\u30b9\u6570\u3088\u308a\u3082\u30ea\u30ea\u30fc\u30b9\u6570\u304c\u5897\u3048\u3066\u3044\u305f\u3089\u30c4\u30a4\u30fc\u30c8<\/strong>\r\n\r\n<strong>            cache()-&gt;put($cache_key, $current_nearest_count); \/\/ \u65b0\u3057\u3044\u30ea\u30ea\u30fc\u30b9\u6570\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u5316<\/strong>\r\n\r\n<strong>            $tweet_body = view('achievement_tweet', ['count' =&gt; $current_nearest_count])-&gt;render();<\/strong>\r\n\r\n<strong>            $connection = new TwitterOAuth(<\/strong>\r\n<strong>                \/\/ \u672c\u6765\u306f config \u304b\u3089\u53d6\u5f97\u3059\u308b\u3079\u304d\u3067\u3059<\/strong>\r\n<strong>                env('TWITTER_CONSUMER_KEY'),<\/strong>\r\n<strong>                env('TWITTER_CONSUMER_SECRET'),<\/strong>\r\n<strong>                env('TWITTER_ACCESS_TOKEN'),<\/strong>\r\n<strong>                env('TWITTER_ACCESS_TOKEN_SECRET')<\/strong>\r\n<strong>            );<\/strong>\r\n<strong>            $connection-&gt;setApiVersion(2);<\/strong>\r\n<strong>            $parameters = [<\/strong>\r\n<strong>                'text' =&gt; $tweet_body,<\/strong>\r\n<strong>            ];<\/strong>\r\n<strong>            $connection-&gt;post('tweets', $parameters, ['jsonPayload' =&gt; true]);<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    private function getNearestCount($count, $nearest_number) { \/\/ \u6307\u5b9a\u3055\u308c\u305f\u6570\u5024\u306e\u500d\u6570\u3067\u4e38\u3081\u308b<\/strong>\r\n\r\n<strong>        return (int) floor($count \/ $nearest_number) * $nearest_number;<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n    \/**\r\n     * Get the channels the event should broadcast on.\r\n     *\r\n     * @return array&lt;int, \\Illuminate\\Broadcasting\\Channel&gt;\r\n     *\/\r\n    public function broadcastOn(): array\r\n    {\r\n        return [\r\n            new PrivateChannel('channel-name'),\r\n        ];\r\n    }\r\n}<\/pre>\n<\/div>\n<p>\u3067\u306f\u3001\u3053\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u30e2\u30c7\u30eb\u306b\u30bb\u30c3\u30c8\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<div>\n<pre>&lt;?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse App\\Events\\ReleaseCreated;\r\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Release extends Model\r\n{\r\n    \/\/ \u7701\u7565\r\n\r\n    <strong>protected $dispatchesEvents = [ \/\/ \ud83d\udc48\u3053\u3053<\/strong>\r\n<strong>        'created' =&gt; ReleaseCreated::class,<\/strong>\r\n<strong>    ];<\/strong>\r\n}<\/pre>\n<\/div>\n<h1>\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u672c\u6587\u3092\u30d3\u30e5\u30fc\u3067\u3064\u304f\u308a\u307e\u3057\u3087\u3046\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n<div>\n<pre><strong>php artisan make:view achievement_tweet<\/strong><\/pre>\n<\/div>\n<p>\u3059\u308b\u3068\u3001\u30d3\u30e5\u30fc\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><strong>resources\/views\/achievement_tweet.blade.php<\/strong><\/p>\n<div>\n<pre><strong>\u3010{{ number_format($count) }}\u4ef6\u7a81\u7834\uff01\u3011\r\n\r\n\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u306e\u63b2\u8f09\u4ef6\u6570\u304c\u3001\r\n{{ number_format($count) }}\u4ef6\u3092\u7a81\u7834\u3057\u307e\u3057\u305f\uff01\r\n\r\n\u3053\u308c\u304b\u3089\u3082\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u306e\u6295\u7a3f\u3001\u63b2\u8f09\u306f\u7121\u6599\u306a\u306e\u3067\r\n\u81ea\u793e\u3001\u500b\u4eba\u30b5\u30fc\u30d3\u30b9\u306e\u96c6\u5ba2\u306b\u6d3b\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002\r\n\r\n\u3054\u6295\u7a3f\u306f\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306e\u30ea\u30f3\u30af\u304b\u3089\u3069\u3046\u305e\uff01<\/strong><\/pre>\n<p>\u3053\u308c\u3067\u4f5c\u696d\u306f\u5b8c\u4e86\u3067\u3059\uff01<br \/>\n\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\u3002\ud83d\ude0a\u2728<\/p>\n<\/div>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<\/p>\n<p>\u60f3\u5b9a\u3059\u308b\u30b9\u30c8\u30fc\u30ea\u30fc\u306f\u3001\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u306e\u4ef6\u6570\u304c<code>99<\/code>\u2192<code>100<\/code>\u306b\u306a\u3063\u305f\u3068\u304d\u3067\u3059\u3002<br \/>\n\u73fe\u5728\u306e\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306f\u3001<code>98<\/code>\u4ef6\u306a\u306e\u3067\u3001<\/p>\n<ul>\n<li>\uff11\u4ef6\u8ffd\u52a0\uff1a \u4f55\u3082\u8d77\u304d\u306a\u3044<\/li>\n<li>\u3055\u3089\u306b\uff11\u4ef6\u8ffd\u52a0\uff1a \u3053\u3053\u3067\u30c4\u30a4\u30fc\u30c8<\/li>\n<\/ul>\n<p>\u304c\u3067\u304d\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067<code>tinker<\/code>\uff08\u30b3\u30de\u30f3\u30c9\u4e0a\u3067<code>PHP<\/code>\u3092\u5b9f\u884c\u3067\u304d\u308b\u30c4\u30fc\u30eb\uff09\u3092\u8d77\u52d5\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<div>\n<pre><strong>php artisan tinker<\/strong><\/pre>\n<\/div>\n<p>\u305d\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30da\u3057\u3066<code>Enter<\/code>\u30ad\u30fc\u3092\u62bc\u3057\u307e\u3059\u3002<\/p>\n<div>\n<pre><strong>\\App\\Models\\Release::create(['body' =&gt; 'test']);<\/strong><\/pre>\n<\/div>\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-12734\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/05\/laravel_achievement_tweet_1.png\" alt=\"\" width=\"349\" height=\"166\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/05\/laravel_achievement_tweet_1.png 349w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/05\/laravel_achievement_tweet_1-300x143.png 300w\" sizes=\"auto, (max-width: 349px) 100vw, 349px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u5b9f\u884c\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u60f3\u5b9a\u901a\u308a\u30c4\u30a4\u30fc\u30c8\u306f\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n<p>\u3067\u306f\u3001\u672c\u756a\u306e<code>100<\/code>\u4ef6\u76ee\u767b\u9332\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n<p>\u3046\u307e\u304f\u3044\u304f\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12735\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/05\/laravel_achievement_tweet_2.png\" alt=\"\" width=\"594\" height=\"254\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/05\/laravel_achievement_tweet_2.png 594w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/05\/laravel_achievement_tweet_2-300x128.png 300w\" sizes=\"auto, (max-width: 594px) 100vw, 594px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\uff08\u30c0\u30fc\u30af\u30e2\u30fc\u30c9\u3067\u7533\u3057\u8a33\u306a\u3044\u3067\u3059\u304c\uff09\u304d\u3061\u3093\u3068\u30c4\u30a4\u30fc\u30c8\u304c\u6295\u7a3f\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u6210\u529f\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<h1>\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h1>\n<p>\u4eca\u56de\u306e\u3088\u3046\u306b\u6a29\u5a01\u6027\u306e\u3042\u308b\u6570\u5024\u3068<code>Twitter<\/code>\uff08X\uff09\u306f\u89aa\u548c\u6027\u304c\u9ad8\u3044\u3067\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001\u3044\u3061\u3044\u3061\u624b\u52d5\u3067\u5909\u66f4\u3059\u308b\u5fc5\u8981\u306f\u306a\u3044\u306e\u3067\u3001\u65e5\u3005\u306e\u696d\u52d9\u306b\u652f\u969c\u304c\u51fa\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3082\u3057\u305d\u3046\u3044\u3063\u305f\u30c4\u30a4\u30fc\u30c8\u904b\u7528\u3092\u3057\u305f\u3044\u65b9\u306f\u305c\u3072\u304a\u554f\u3044\u5408\u308f\u305b\u304b\u3089\u3054\u76f8\u8ac7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059\u3002\ud83d\ude0a\u2728<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u6a29\u5a01\u6027\u3092\u3064\u304b\u3063\u305f\u30c4\u30a4\u30fc\u30c8\u3092\u81ea\u52d5\u3067\u6295\u7a3f\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u4e00\u5ea6\u69cb\u7bc9\u3057\u3066\u3057\u307e\u3048\u3070\u3001\u3042\u3068\u306f\u7279\u5225\u96e3\u3057\u3044\u3053\u3068\u306f\u3057\u3066\u306a\u3044\u306e\u3067\u3001\u4fbf\u5229\uff06\u52b9\u679c\u3082\u3067\u3084\u3059\u3044\u3093\u3058\u3083\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u4e00\u5ea6\u8a66\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-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\" \/>\u300c\u5d16\u306e\u4e0a\u306e\u30dd\u30cb\u30e7\u306e\u30e2\u30c7\u30eb\u306b\u306a\u3063\u305f<br \/>\n\u9786\u306e\u6d66\u306b\u884c\u3063\u3066\u304d\u307e\u3057\u305f\u3002\u611f\u52d5\uff01\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u79c1\u306f\u500b\u4eba\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u300c\u3077\u308c\u308a\u308a\u300d\u3068\u3044\u3046\u540d\u524d\u306e\u300c\u7121\u6599\u3067\u4f7f\u3048\u308b\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u300d\u30b9\u30bf\u30f3\u30c9\u3092\u904b\u55b6\u3057\u3066\u3044\u307e\u3059\u3002 \u307b\u307c\u30dc\u30e9\u30f3\u30c6\u30a3\u30a2\u3067\u904b\u55b6\u3057\u3066\u308b\u3093\u3067\u3059\u304c 2024 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=12733\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel\uff1a\u6a29\u5a01\u6027\u304c\u3042\u308b\u30c4\u30a4\u30fc\u30c8\u3092\u81ea\u52d5\u6295\u7a3f\u3059\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":12740,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,258],"tags":[192],"class_list":["post-12733","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-258","tag-twitter"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/12733","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=12733"}],"version-history":[{"count":3,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/12733\/revisions"}],"predecessor-version":[{"id":12741,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/12733\/revisions\/12741"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/12740"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}