29 lines
690 B
PHP
29 lines
690 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Post;
|
|
use App\Services\PostMediaCacher;
|
|
use Illuminate\Console\Attributes\Description;
|
|
use Illuminate\Console\Attributes\Signature;
|
|
use Illuminate\Console\Command;
|
|
|
|
#[Signature('posts:cache-media')]
|
|
#[Description('Download and locally cache any post media still pointing at Instagram\'s CDN')]
|
|
class CachePostMedia extends Command
|
|
{
|
|
public function handle(PostMediaCacher $mediaCacher): int
|
|
{
|
|
$count = 0;
|
|
|
|
foreach (Post::query()->cursor() as $post) {
|
|
$mediaCacher->cache($post);
|
|
$count++;
|
|
}
|
|
|
|
$this->info("Checked {$count} posts.");
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|