Changed links to chapters, button to synchronize chapters from courses list, dark mode.
This commit is contained in:
@@ -4,11 +4,14 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\SymfonyCastDl\SymfonyCastDlService;
|
||||
use App\Models\Chapter;
|
||||
use App\Models\Course;
|
||||
|
||||
class ChapterController extends Controller
|
||||
{
|
||||
public function index(Chapter $chapter, SymfonyCastDlService $symfonyCastDlService)
|
||||
public function index(Course $course, int $chapter, SymfonyCastDlService $symfonyCastDlService)
|
||||
{
|
||||
$chapter = $course->chapters->firstWhere('order', $chapter);
|
||||
|
||||
$symfonyCastDlService->videoSize($chapter);
|
||||
if ($chapter->sync_offline) {
|
||||
$symfonyCastDlService->downloadFile($chapter);
|
||||
|
||||
@@ -16,11 +16,11 @@ class CourseController extends Controller
|
||||
return view('course.index', compact('course'));
|
||||
}
|
||||
|
||||
public function sync(Course $course)
|
||||
public function sync(Course $course): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$course->chapters->each->update(['sync_offline' => 1]);
|
||||
$course->chapters->each(fn($chapter) => DownloadVideoFile::dispatch($chapter->id));
|
||||
return redirect(route('course.index', ['course' => $course]));
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +1,40 @@
|
||||
<x-layout>
|
||||
<h1>
|
||||
<a href="/">List</a> » <a
|
||||
href="{{ route('course.index', ['course' => $chapter->course_id]) }}">{{ $chapter->course->name }}</a>
|
||||
<a href="/" class="text-decoration-none">List</a> » <a class="text-decoration-none"
|
||||
href="{{ route('course.index', ['course' => $chapter->course_id]) }}">{{ $chapter->course->name }}</a>
|
||||
<br>
|
||||
<small class="text-muted">{{ $chapter->title }}</small>
|
||||
</h1>
|
||||
<div>
|
||||
<div class="float-none">
|
||||
@if($prev)
|
||||
<div class="float-start m-2"><a href="{{ route('course.chapter', ['chapter' => $prev->id]) }}">Prev</a>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@if($prev)
|
||||
<div class="float-start m-2"><a
|
||||
href="{{ route('course.chapter', ['course' => $chapter->course_id, 'chapter' => $prev->order]) }}"
|
||||
class="btn btn-primary">Prev</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
@if($next)
|
||||
<div class="float-end m-2"><a href="{{ route('course.chapter', ['chapter' => $next->id]) }}">Next</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col">
|
||||
@if($chapter->is_video_file)
|
||||
<div class="d-flex justify-content-center">
|
||||
<video class="mx-auto" width="500" controls>
|
||||
<source src="{{ $chapter->video_url }}" type="video/mp4"/>
|
||||
</video>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="mx-auto" style="width: 500px;">
|
||||
@if($chapter->is_video_file)
|
||||
<video class="mx-auto" width="500" controls>
|
||||
<source src="{{ $chapter->video_url }}" type="video/mp4"/>
|
||||
</video>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col">
|
||||
@if($next)
|
||||
<div class="float-end m-2"><a
|
||||
href="{{ route('course.chapter', ['course' => $chapter->course_id, 'chapter' => $next->order]) }}"
|
||||
class="btn btn-primary">Next</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-layout>
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>{{ $title ?? 'Symfonycast.local' }}</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
crossorigin="anonymous">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-dark-5@1.1.3/dist/css/bootstrap-nightfall.min.css"
|
||||
rel="stylesheet" media="(prefers-color-scheme: dark)">
|
||||
</head>
|
||||
<body>
|
||||
{{ $slot }}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<x-layout>
|
||||
<h1>
|
||||
<a href="/">List</a> » {{ $course->name }}
|
||||
<a href="/" class="text-decoration-none">List</a> » {{ $course->name }}
|
||||
</h1>
|
||||
|
||||
<a href="{{ route('course.sync', ['course' => $course->id]) }}">Sync all chapters offline</a>
|
||||
@@ -16,7 +16,7 @@
|
||||
</thead>
|
||||
@foreach($course->chapters()->get() as $chapter)
|
||||
<tr>
|
||||
<td><a href="{{ route('course.chapter', ['chapter' => $chapter->id]) }}">{{ $chapter->title }}</a></td>
|
||||
<td><a href="{{ route('course.chapter', ['course' => $course->id, 'chapter' => $chapter->order]) }}" class="text-decoration-none">{{ $chapter->title }}</a></td>
|
||||
<td>{{ $chapter->duration }}</td>
|
||||
<td>{{ $chapter->sync_offline?'Yes':'no' }}</td>
|
||||
<td>{{ $chapter->is_video_file?'Yes':'-' }}</td>
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
<th>Id</th>
|
||||
<th></th>
|
||||
<th>Name</th>
|
||||
<th>status</th>
|
||||
<th>Status</th>
|
||||
<th>Sync</th>
|
||||
<th>Chapters</th>
|
||||
<th>Published at</th>
|
||||
<th>Estimate file size</th>
|
||||
@@ -18,9 +19,13 @@
|
||||
<td class="align-middle">{{ $course->id }}</td>
|
||||
<td><img src="{{ $course->thumbnail }}" alt="{{ $course->name }}" class="img-thumbnail"
|
||||
style="width: 70px;"></td>
|
||||
<td class="align-middle"><a
|
||||
href="{{ route('course.index', ['course' => $course->id]) }}">{{ $course->name }}</a></td>
|
||||
<td class="align-middle"><a class="text-decoration-none"
|
||||
href="{{ route('course.index', ['course' => $course->id]) }}">{{ $course->name }}</a>
|
||||
</td>
|
||||
<td class="align-middle">{{ $course->status }}</td>
|
||||
<td class="align-middle"><a class="btn btn-outline-primary"
|
||||
href="{{ route('course.sync', ['course' => $course->id]) }}">Sync all
|
||||
chapters offline</a></td>
|
||||
<td class="align-middle">{{ $course->chapters_count }} / {{ $course->numberofchapters }}</td>
|
||||
<td class="align-middle"><abbr
|
||||
title="{{ $course->published_at?->format('Y-m-d') }}">{{ $course->published_at?->diffForHumans() }}</abbr>
|
||||
|
||||
@@ -21,7 +21,7 @@ Route::get('/', [Index::class, 'index']);
|
||||
Route::prefix('course')->name('course.')->group(function () {
|
||||
Route::get('/{course}', [CourseController::class, 'index'])->name('index');
|
||||
Route::get('/{course}/sync', [CourseController::class, 'sync'])->name('sync');
|
||||
Route::get('/{course}/chapter/{chapter}', [ChapterController::class, 'index'])->name('chapter');
|
||||
});
|
||||
Route::get('/chapter/{chapter}', [ChapterController::class, 'index'])->name('course.chapter');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user