Add tests for featured thumbnail generation; apply Pint formatting and related edits
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user