Files
dredgegram/app/Console/Commands/CachePostMedia.php
T
dredgy b2f2d8b104
linter / quality (push) Canceled after 0s
tests / ci (8.3) (push) Canceled after 0s
tests / ci (8.4) (push) Canceled after 0s
tests / ci (8.5) (push) Canceled after 0s
Initial Commit
2026-08-29 00:17:41 +10:00

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;
}
}