Skip to content

Commit aa1468c

Browse files
committed
WIP
1 parent 02c6cf8 commit aa1468c

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ TELEGRAM_CHANNEL=
4949

5050
FATHOM_SITE_ID=
5151
FATHOM_TOKEN=
52+
53+
UNSPLASH_ACCESS_KEY=
54+
5255
LOG_STACK=single
5356
SESSION_ENCRYPT=false
5457
SESSION_PATH=/
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
@@ -40,4 +40,8 @@
4040
'token' => env('FATHOM_TOKEN'),
4141
],
4242

43+
'unsplash' => [
44+
'acccess_key' => env('UNSPLASH_ACCESS_KEY'),
45+
],
46+
4347
];

0 commit comments

Comments
 (0)