diff --git a/.env.example b/.env.example index c604d587e..45fd5e6ef 100644 --- a/.env.example +++ b/.env.example @@ -38,3 +38,5 @@ TELEGRAM_CHANNEL= FATHOM_SITE_ID= FATHOM_TOKEN= + +UNSPLASH_ACCESS_KEY= \ No newline at end of file diff --git a/app/Console/Commands/SyncArticleImages.php b/app/Console/Commands/SyncArticleImages.php new file mode 100644 index 000000000..d041ab189 --- /dev/null +++ b/app/Console/Commands/SyncArticleImages.php @@ -0,0 +1,39 @@ +accessKey = config('services.unsplash.access_key'); + } + + public function handle(): void + { + if (! $this->accessKey) { + $this->error('Unsplash access key must be configured'); + + return; + } + + Article::published()->chunk(100, function ($articles) { + $articles->each(function ($article) { + if (! $article->hero_image) { + // Update Unsplash image URL + } + }); + }); + } +} diff --git a/config/services.php b/config/services.php index b343f6757..ffbf889e3 100644 --- a/config/services.php +++ b/config/services.php @@ -62,4 +62,8 @@ 'token' => env('FATHOM_TOKEN'), ], + 'unsplash' => [ + 'acccess_key' => env('UNSPLASH_ACCESS_KEY'), + ], + ];