From 57d7f639ffb9f23aee1135e1a6fa0c3dcc268c6d Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Thu, 30 May 2024 21:24:06 +0100 Subject: [PATCH] stub out unsplash integration --- .env.example | 2 ++ app/Console/Commands/SyncArticleImages.php | 39 ++++++++++++++++++++++ config/services.php | 4 +++ 3 files changed, 45 insertions(+) create mode 100644 app/Console/Commands/SyncArticleImages.php 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'), + ], + ];