Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ TELEGRAM_CHANNEL=

FATHOM_SITE_ID=
FATHOM_TOKEN=

UNSPLASH_ACCESS_KEY=
39 changes: 39 additions & 0 deletions app/Console/Commands/SyncArticleImages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Console\Commands;

use App\Models\Article;
use Illuminate\Console\Command;

final class SyncArticleImages extends Command
{
protected $signature = 'lio:sync-article-images';

protected $description = 'Updates the Unsplash image for all articles';

protected $accessKey;

public function __construct()
{
parent::__construct();

$this->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
}
});
});
}
}
4 changes: 4 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@
'token' => env('FATHOM_TOKEN'),
],

'unsplash' => [
'acccess_key' => env('UNSPLASH_ACCESS_KEY'),
],

];