29 خطوط
644 B
PHP
29 خطوط
644 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
class Comment extends Model
|
|
{
|
|
protected $fillable = ['body', 'user_id', 'commentable_id', 'commentable_type'];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function commentable(): MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
public function files(): MorphMany
|
|
{
|
|
return $this->morphMany(File::class, 'fileable');
|
|
}
|
|
}
|