| Total Complexity | 4 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class ForumTopic extends Model |
||
| 10 | { |
||
| 11 | use HasFactory; |
||
| 12 | |||
| 13 | protected $fillable = ['category_id', 'title', 'slug', 'content', 'created_by']; |
||
| 14 | protected $dates = ['created_at', 'updated_at']; |
||
| 15 | |||
| 16 | protected static function boot() |
||
| 17 | { |
||
| 18 | parent::boot(); |
||
| 19 | |||
| 20 | static::creating(function ($topic) { |
||
| 21 | $topic->slug = Str::slug($topic->title); |
||
| 22 | }); |
||
| 23 | } |
||
| 24 | |||
| 25 | public function category() |
||
| 26 | { |
||
| 27 | return $this->belongsTo(ForumCategory::class, 'category_id'); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function author() |
||
| 31 | { |
||
| 32 | return $this->belongsTo(User::class, 'created_by'); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function posts() |
||
| 38 | } |
||
| 39 | } |
||
| 40 |