Add tests for featured thumbnail generation; apply Pint formatting and related edits

This commit is contained in:
2026-05-06 18:55:40 +02:00
parent 7a8bc8e22a
commit 82f2b1f660
65 changed files with 11325 additions and 49545 deletions

View File

@@ -14,6 +14,21 @@ class AcademyLesson extends Model
{
use SoftDeletes;
protected static function booted(): void
{
static::deleting(function (self $lesson): void {
$lesson->blocks()->with('comparisonResults')->get()->each(function (AcademyLessonBlock $block) use ($lesson): void {
if ($lesson->isForceDeleting()) {
$block->forceDelete();
return;
}
$block->delete();
});
});
}
protected $fillable = [
'category_id',
'title',
@@ -59,4 +74,16 @@ class AcademyLesson extends Model
{
return $this->hasMany(AcademyLessonProgress::class, 'lesson_id');
}
}
public function blocks(): HasMany
{
return $this->hasMany(AcademyLessonBlock::class, 'lesson_id')
->orderBy('sort_order')
->orderBy('id');
}
public function activeBlocks(): HasMany
{
return $this->blocks()->where('active', true);
}
}