Files
shahrzadzandi09/app/Models/Comment.php
T
2026-08-15 13:37:07 +03:30

65 lines
1.1 KiB
PHP

<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class Comment
*
* @property int $id
* @property int $user_id
* @property int $commentable_id
* @property string $commentable_type
* @property string $body
* @property int $status
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property User $user
* @property Comment $comment
* @property Collection|Comment[] $comments
*
* @package App\Models
*/
class Comment extends Model
{
protected $table = 'comments';
public static $snakeAttributes = false;
protected $casts = [
'user_id' => 'int',
'commentable_id' => 'int',
'status' => 'int'
];
protected $fillable = [
'user_id',
'commentable_id',
'commentable_type',
'body',
'status'
];
public function user()
{
return $this->belongsTo(User::class);
}
public function comment()
{
return $this->belongsTo(Comment::class, 'commentable_id');
}
public function comments()
{
return $this->hasMany(Comment::class, 'commentable_id');
}
}