/
DATKAI
/
ITCUP
Обзор
Документация
Войти
/
DATKAI
/
ITCUP
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
app/Models/KnowledgeCategory.php
54 строки
1 KB
ITCUP Admin
feat(knowledge): база знаний — статьи, FAQ, инциденты, troubleshooting
21 апр 2026, 22:32
21 апр 2026, 22:32
979fad3
Код
Авторство
О чём код?
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Support\Str; class KnowledgeCategory extends Model { protected $fillable = [ 'name', 'slug', 'icon', 'color', 'description', 'default_is_public', 'is_active', 'sort_order', ]; protected $casts = [ 'default_is_public' => 'boolean', 'is_active' => 'boolean', ]; public const COLORS = [ 'gray' => 'Серый', 'primary' => 'Синий', 'info' => 'Голубой', 'success' => 'Зелёный', 'warning' => 'Жёлтый', 'danger' => 'Красный', ]; protected static function booted(): void { static::creating(function (KnowledgeCategory $c) { if (empty($c->slug)) { $c->slug = Str::slug($c->name); } }); } public function articles(): HasMany { return $this->hasMany(KnowledgeArticle::class); } public function customFields(): HasMany { return $this->hasMany(KnowledgeCustomField::class)->orderBy('sort_order'); } }