trypost/app/Jobs/ProcessScheduledPosts.php
2026-01-14 22:13:44 -03:00

24 lines
549 B
PHP

<?php
namespace App\Jobs;
use App\Models\Post;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
class ProcessScheduledPosts implements ShouldQueue
{
use Queueable;
public function handle(): void
{
Post::query()
->due()
->with(['postPlatforms.socialAccount', 'postPlatforms.media'])
->chunk(100, function ($posts) {
foreach ($posts as $post) {
PublishPost::dispatch($post);
}
});
}
}