Files
LMS/app/Models/CourseModule.php
mirivladandQwen-Coder 41224069c1 Feat: Модули курса (контент)
 CourseModuleController (store, update, destroy)
 Маршруты для модулей
 UI добавления/редактирования модулей
 Типы: section, lesson, video, file, link, test
 Тесты как тип модуля (выбор из существующих)
 Загрузка файлов
 Иерархия (родитель/потомки)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-02 17:27:49 +08:00

65 lines
1.4 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class CourseModule extends Model
{
use HasFactory;
protected $fillable = [
'course_id',
'parent_id',
'title',
'content',
'type', // section, lesson, video, file, link, test
'sort_order',
'duration_minutes',
'is_required',
'is_active',
'video_url',
'file_path',
'external_url',
'test_id', // Связь с тестом
];
protected $casts = [
'is_required' => 'boolean',
'is_active' => 'boolean',
];
public function course(): BelongsTo
{
return $this->belongsTo(Course::class);
}
public function parent(): BelongsTo
{
return $this->belongsTo(CourseModule::class, 'parent_id');
}
public function children(): HasMany
{
return $this->hasMany(CourseModule::class, 'parent_id');
}
public function tests(): HasMany
{
return $this->hasMany(Test::class);
}
public function test(): BelongsTo
{
return $this->belongsTo(Test::class);
}
public function userProgress(): HasMany
{
return $this->hasMany(UserCourseProgress::class);
}
}