true, 'status' => DocumentationVersionStatus::CurrentVersion, ]; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'title', 'slug', 'is_public', 'status', ]; /** * The "booted" method of the model. */ protected static function booted(): void { static::addGlobalScope('status', function (Builder $builder) { $builder->orderBy('status', 'desc'); }); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'is_public' => 'boolean', 'status' => DocumentationVersionStatus::class, ]; } public function project(): BelongsTo { return $this->belongsTo(Project::class); } public function documentations(): HasMany { return $this->hasMany(Documentation::class, 'version_id'); } public function categories(): HasMany { return $this->hasMany(DocumentationCategory::class, 'version_id'); } }