29 lines
569 B
PHP
29 lines
569 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Topic extends Model
|
|
{
|
|
use HasFactory;
|
|
protected $table = 'topics';
|
|
protected $fillable = ['user_id', 'title', 'content', 'is_pinned'];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function comments()
|
|
{
|
|
return $this->hasMany(Comment::class);
|
|
}
|
|
|
|
public function likes()
|
|
{
|
|
return $this->morphMany(Like::class, 'likeable');
|
|
}
|
|
}
|