Info and filtering by course tracks, table of content on chapter view with links and previous and next buttons.
This commit is contained in:
@@ -9,9 +9,9 @@ use Illuminate\Http\Request;
|
|||||||
|
|
||||||
class Index extends Controller
|
class Index extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index(string $track = null)
|
||||||
{
|
{
|
||||||
$courses = Course::with('chapters')->withCount('chapters')->get();
|
$courses = Course::where('tracks', 'like', '%'.$track.'%')->with('chapters')->withCount('chapters')->get();
|
||||||
|
|
||||||
return view('index', compact(['courses']));
|
return view('index', compact(['courses']));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class HtmlParser
|
|||||||
$course->thumbnail = $courseItem->first('img.course-list-item-img')->attr('src');
|
$course->thumbnail = $courseItem->first('img.course-list-item-img')->attr('src');
|
||||||
$course->link = last(explode('/', $courseItem->first('a')->attr('href')));
|
$course->link = last(explode('/', $courseItem->first('a')->attr('href')));
|
||||||
$course->status = $courseItem->attr('data-status');
|
$course->status = $courseItem->attr('data-status');
|
||||||
|
$course->tracks = $courseItem->attr('data-tracks');
|
||||||
$course->course_id = $courseItem->attr('data-id');
|
$course->course_id = $courseItem->attr('data-id');
|
||||||
$course->numberofchapters = $courseItem->attr('data-chapter-count');
|
$course->numberofchapters = $courseItem->attr('data-chapter-count');
|
||||||
$course->timeswatched = $courseItem->attr('data-times-watched');
|
$course->timeswatched = $courseItem->attr('data-times-watched');
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
* @property string $thumbnail
|
* @property string $thumbnail
|
||||||
* @property string $link
|
* @property string $link
|
||||||
* @property string $status
|
* @property string $status
|
||||||
|
* @property string $tracks
|
||||||
* @property integer $numberofchapters
|
* @property integer $numberofchapters
|
||||||
* @property integer $timeswatched
|
* @property integer $timeswatched
|
||||||
* @property Date $published_at
|
* @property Date $published_at
|
||||||
@@ -28,6 +29,7 @@ class Course extends Model
|
|||||||
'thumbnail',
|
'thumbnail',
|
||||||
'link',
|
'link',
|
||||||
'status',
|
'status',
|
||||||
|
'tracks',
|
||||||
'numberofchapters',
|
'numberofchapters',
|
||||||
'timeswatched',
|
'timeswatched',
|
||||||
'published_at',
|
'published_at',
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.0.2",
|
"php": "^8.0.2",
|
||||||
|
"doctrine/dbal": "^3.5",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"imangazaliev/didom": "^2.0",
|
"imangazaliev/didom": "^2.0",
|
||||||
"laravel/framework": "^9.19",
|
"laravel/framework": "^9.19",
|
||||||
|
|||||||
1449
composer.lock
generated
1449
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('courses', function (Blueprint $table) {
|
||||||
|
$table->text('tracks')->after('status')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('courses', function (Blueprint $table) {
|
||||||
|
$table->removeColumn('tracks');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -25,6 +25,19 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<table class="table table-sm">
|
||||||
|
@foreach($chapters as $courseChapter)
|
||||||
|
<tr class="@if($courseChapter->id === $chapter->id)table-dark @endif">
|
||||||
|
<td>
|
||||||
|
<a href="{{ route('course.chapter', ['course' => $courseChapter->course_id, 'chapter' => $courseChapter->order ]) }}" class="text-decoration-none">{{ $courseChapter->title }}</a>
|
||||||
|
</td>
|
||||||
|
<td class="text-end">{{ $courseChapter->duration }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
@if($next)
|
@if($next)
|
||||||
@@ -35,6 +48,7 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</x-layout>
|
</x-layout>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
<th>Tracks</th>
|
||||||
<th>Sync</th>
|
<th>Sync</th>
|
||||||
<th>Chapters</th>
|
<th>Chapters</th>
|
||||||
<th>Published at</th>
|
<th>Published at</th>
|
||||||
@@ -23,6 +24,11 @@
|
|||||||
href="{{ route('course.index', ['course' => $course->id]) }}">{{ $course->name }}</a>
|
href="{{ route('course.index', ['course' => $course->id]) }}">{{ $course->name }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">{{ $course->status }}</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">{{ $track }}</a>
|
||||||
|
@endforeach
|
||||||
|
</td>
|
||||||
<td class="align-middle"><a class="btn btn-outline-primary"
|
<td class="align-middle"><a class="btn btn-outline-primary"
|
||||||
href="{{ route('course.sync', ['course' => $course->id]) }}">Sync all
|
href="{{ route('course.sync', ['course' => $course->id]) }}">Sync all
|
||||||
chapters offline</a></td>
|
chapters offline</a></td>
|
||||||
@@ -41,6 +47,7 @@
|
|||||||
<td></td>
|
<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($courses->sum('total_size')) }}</td>
|
||||||
<td class="align-middle text-end pe-4">{{formatFileSize(folderSize(public_path()))}}</td>
|
<td class="align-middle text-end pe-4">{{formatFileSize(folderSize(public_path()))}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use Illuminate\Support\Facades\Route;
|
|||||||
|
|
||||||
Route::get('/download', [Index::class, 'download']);
|
Route::get('/download', [Index::class, 'download']);
|
||||||
Route::get('/', [Index::class, 'index']);
|
Route::get('/', [Index::class, 'index']);
|
||||||
|
Route::get('/track/{track}', [Index::class, 'index']);
|
||||||
Route::prefix('course')->name('course.')->group(function () {
|
Route::prefix('course')->name('course.')->group(function () {
|
||||||
Route::get('/{course}', [CourseController::class, 'index'])->name('index');
|
Route::get('/{course}', [CourseController::class, 'index'])->name('index');
|
||||||
Route::get('/{course}/sync', [CourseController::class, 'sync'])->name('sync');
|
Route::get('/{course}/sync', [CourseController::class, 'sync'])->name('sync');
|
||||||
|
|||||||
Reference in New Issue
Block a user