Added helper file, replaced size file for human version as a helper method, next prev buttons for chapters.

This commit is contained in:
Krzysztof Płaczek
2022-12-07 11:37:50 +01:00
parent b992d05312
commit 25e28f8193
7 changed files with 82 additions and 16 deletions

View File

@@ -1,14 +1,26 @@
<x-layout>
<h1>
{{ $chapter->course->name }}
<a href="/">List</a> &raquo; <a
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>
@endif
@if($next)
<div class="float-end m-2"><a href="{{ route('course.chapter', ['chapter' => $next->id]) }}">Next</a>
</div>
@endif
</div>
<div class="mx-auto" style="width: 500px;">
@if($chapter->is_video_file)
<video class="mx-auto" width="500" controls>
<source src="/{{ $chapter->video_path }}" type="video/mp4"/>
<source src="{{ $chapter->video_url }}" type="video/mp4"/>
</video>
@endif
</div>

View File

@@ -9,17 +9,35 @@
<th>status</th>
<th>Chapters</th>
<th>Published at</th>
<th>Estimate file size</th>
<th>Actual size</th>
</tr>
</thead>
@foreach($courses as $course)
<tr>
<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><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">{{ $course->status }}</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></td>
<td class="align-middle"><abbr
title="{{ $course->published_at?->format('Y-m-d') }}">{{ $course->published_at?->diffForHumans() }}</abbr>
</td>
<td class="align-middle text-end pe-4">{{ $course->total_size_human }}</td>
<td class="align-middle text-end pe-4">{{formatFileSize(folderSize(public_path($course->id)))}}</td>
</tr>
@endforeach
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="align-middle text-end pe-4">{{ formatFileSize($courses->sum('total_size')) }}</td>
<td class="align-middle text-end pe-4">{{formatFileSize(folderSize(public_path()))}}</td>
</tr>
</table>
</x-layout>