Skip to content

Commit 57d7f63

Browse files
committed
stub out unsplash integration
1 parent 87d74b2 commit 57d7f63

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ TELEGRAM_CHANNEL=
3838

3939
FATHOM_SITE_ID=
4040
FATHOM_TOKEN=
41+
42+
UNSPLASH_ACCESS_KEY=
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Models\Article;
6+
use Illuminate\Console\Command;
7+
8+
final class SyncArticleImages extends Command
9+
{
10+
protected $signature = 'lio:sync-article-images';
11+
12+
protected $description = 'Updates the Unsplash image for all articles';
13+
14+
protected $accessKey;
15+
16+
public function __construct()
17+
{
18+
parent::__construct();
19+
20+
$this->accessKey = config('services.unsplash.access_key');
21+
}
22+
23+
public function handle(): void
24+
{
25+
if (! $this->accessKey) {
26+
$this->error('Unsplash access key must be configured');
27+
28+
return;
29+
}
30+
31+
Article::published()->chunk(100, function ($articles) {
32+
$articles->each(function ($article) {
33+
if (! $article->hero_image) {
34+
// Update Unsplash image URL
35+
}
36+
});
37+
});
38+
}
39+
}

config/services.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@
6262
'token' => env('FATHOM_TOKEN'),
6363
],
6464

65+
'unsplash' => [
66+
'acccess_key' => env('UNSPLASH_ACCESS_KEY'),
67+
],
68+
6569
];

0 commit comments

Comments
 (0)