where('created_at', '>', now()->subHours(1)) ->whereNull('remote_url') ->whereNotNull('status_id') ->whereNotNull('media_path') ->whereIn('mime', [ 'image/jpeg', 'image/png', ]) ->chunk(50, function($medias) { foreach ($medias as $media) { if ($media->skip_optimize) continue; ImageOptimize::dispatch($media); } }); } }