migrate to gtea from bistbucket
This commit is contained in:
35
app/Models/Comment.php
Normal file
35
app/Models/Comment.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Comment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = ['name', 'email', 'comment', 'blog_id'];
|
||||
|
||||
public function blog(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Blog::class);
|
||||
}
|
||||
|
||||
public function parentComment(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Comment::class, 'comment_id');
|
||||
}
|
||||
|
||||
public function replies(): HasMany
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'comment_id');
|
||||
}
|
||||
|
||||
protected $casts = [
|
||||
'blog_id' => 'integer',
|
||||
'comment_id' => 'integer',
|
||||
'status' => 'integer'
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user