Files

35 lines
1.2 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Http\SymfonyCastDl\SymfonyCastDlService;
use App\Jobs\DownloadVideoFile;
use App\Jobs\GetVideoFileSize;
use App\Models\Chapter;
use App\Models\Course;
use Illuminate\Console\Command;
class Update extends Command
{
protected $signature = 'symfonycast:update';
protected $description = 'Updates information about courses and chapters';
public function handle(SymfonyCastDlService $symfonyCastDlService)
{
if (!$symfonyCastDlService->isSubscriptionActive()) {
$this->error('To fully update courses and chapters you need active subscription');
return self::FAILURE;
}
$this->info('Start updating courses');
$courses = $symfonyCastDlService->updateCourses();
$this->output->success(count($courses) . ' courses updated');
$this->output->info('Start updating each course chapters');
$this->withProgressBar($courses, function (Course $course) use ($symfonyCastDlService) {
$symfonyCastDlService->updateChapters($course);
});
$this->output->success('Course chapters updated.');
return self::SUCCESS;
}
}