marking chapters as complete and toggling value from course list and chapter page.

This commit is contained in:
Krzysztof Płaczek
2023-06-13 16:39:20 +02:00
parent 018597faaa
commit 301244cdb0
7 changed files with 45 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers\Chapter;
use App\Http\Controllers\Controller;
use App\Models\Chapter;
use App\Models\Course;
use Illuminate\Http\RedirectResponse;
class CompleteToggle extends Controller
{
public function __invoke(Course $course, Chapter $chapter): RedirectResponse
{
$chapter->update(['is_complete' => !$chapter->is_complete]);
return redirect()->back();
}
}

View File

@@ -17,6 +17,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property string $duration
* @property integer $course_id
* @property bool $sync_offline
* @property bool $is_complete
* @property string $video_path
* @property string $directory_path
* @property Course $course
@@ -34,6 +35,7 @@ class Chapter extends Model
'duration',
'course_id',
'sync_offline',
'is_complete',
];
protected $appends = ['video_path', 'directory_path', 'video_url'];