Updated composer packaged, updated home view table.
This commit is contained in:
@@ -45,14 +45,21 @@ class Course extends Model
|
||||
return $this->hasMany(Chapter::class);
|
||||
}
|
||||
|
||||
public function totalSize(): Attribute
|
||||
protected function totalSize(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => $this->chapters->sum('video_size'),
|
||||
);
|
||||
}
|
||||
|
||||
public function totalSizeHuman(): Attribute
|
||||
protected function tracks(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn(string $tracks) => empty($tracks) ? [] : explode(',', $tracks),
|
||||
);
|
||||
}
|
||||
|
||||
protected function totalSizeHuman(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => formatFileSize($this->total_size),
|
||||
|
||||
893
composer.lock
generated
893
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,53 +1,43 @@
|
||||
<x-layout>
|
||||
<h1>List of Courses</h1>
|
||||
<h1><a class="text-decoration-none" href="{{route('index')}}">List of Courses</a> <small class="text-muted">{{ request()->has('track')?:request()->track }}</small></h1>
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th></th>
|
||||
<th>Name</th>
|
||||
<th>Status</th>
|
||||
<th>Tracks</th>
|
||||
<th>Sync</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 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">
|
||||
@foreach( explode(',', $course->tracks) as $track)
|
||||
<a href="/track/{{ $track }}" class="badge rounded-pill bg-secondary text-decoration-none">{{ $track }}</a>
|
||||
<a class="text-decoration-none" href="{{ route('course.index', ['course' => $course->id]) }}">{{ $course->name }}</a>
|
||||
<p class="text-muted">
|
||||
course status: <span class="fw-lighter">{{ $course->status }}</span>
|
||||
published: <span class="fw-lighter"><abbr title="{{ $course->published_at?->format('Y-m-d') }}">{{ $course->published_at?->diffForHumans() }}</abbr></span>
|
||||
synced chapters: <span class="fw-lighter">{{ $course->chapters_to_sync }} of {{ $course->numberofchapters }}</span>
|
||||
</p>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@foreach($course->tracks as $track)
|
||||
|
||||
<a href="{{ route('index.track', ['track' => $track]) }}" class="badge rounded-pill bg-secondary text-decoration-none">{{ $track }}</a>
|
||||
@endforeach
|
||||
</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_to_sync }} / {{ $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 text-end pe-4">{{ $course->total_size_human }}</td>
|
||||
<td class="align-middle text-end pe-4">{{formatFileSize(folderSize(public_path('videos'.DIRECTORY_SEPARATOR.$course->id)))}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td colspan="4"></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>
|
||||
|
||||
@@ -7,8 +7,8 @@ use App\Http\Controllers\Index;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/download', [Index::class, 'download']);
|
||||
Route::get('/', [Index::class, 'index']);
|
||||
Route::get('/track/{track}', [Index::class, 'index']);
|
||||
Route::get('/', [Index::class, 'index'])->name('index');
|
||||
Route::get('/track/{track}', [Index::class, 'index'])->name('index.track');
|
||||
Route::prefix('course')->group(function () {
|
||||
Route::get('/{course}', CourseController::class)->name('course.index');
|
||||
Route::get('/{course}/sync', Sync::class)->name('course.sync');
|
||||
|
||||
Reference in New Issue
Block a user