Files
symfonycast.local/app/Http/Controllers/ChapterController.php

23 lines
724 B
PHP

<?php
namespace App\Http\Controllers;
use App\Http\SymfonyCastDl\SymfonyCastDlService;
use App\Models\Chapter;
class ChapterController extends Controller
{
public function index(Chapter $chapter, SymfonyCastDlService $symfonyCastDlService)
{
$symfonyCastDlService->videoSize($chapter);
if ($chapter->sync_offline) {
$symfonyCastDlService->downloadFile($chapter);
}
$chapters = $chapter->course->chapters;
$next = $chapters->where('order', '>', $chapter->order)->first();
$prev = $chapters->where('order', '<', $chapter->order)->sortByDesc('order')->first();
return view('chapter.index', compact('chapter', 'chapters', 'prev', 'next'));
}
}