File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ TELEGRAM_CHANNEL=
49
49
50
50
FATHOM_SITE_ID =
51
51
FATHOM_TOKEN =
52
+
53
+ UNSPLASH_ACCESS_KEY =
54
+
52
55
LOG_STACK = single
53
56
SESSION_ENCRYPT = false
54
57
SESSION_PATH = /
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 40
40
'token ' => env ('FATHOM_TOKEN ' ),
41
41
],
42
42
43
+ 'unsplash ' => [
44
+ 'acccess_key ' => env ('UNSPLASH_ACCESS_KEY ' ),
45
+ ],
46
+
43
47
];
You can’t perform that action at this time.
0 commit comments