Initial Commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user