48 lines
877 B
PHP
48 lines
877 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class PhotoComment extends Model
|
|
{
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'commentor_name',
|
|
'commentor_email',
|
|
'comment_text'
|
|
];
|
|
|
|
public function approvedBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'approved_user_id');
|
|
}
|
|
|
|
public function createdBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_user_id');
|
|
}
|
|
|
|
public function depth()
|
|
{
|
|
$depth = 0;
|
|
$current = $this;
|
|
|
|
while (!is_null($current->parent))
|
|
{
|
|
$current = $current->parent;
|
|
$depth++;
|
|
}
|
|
|
|
return $depth;
|
|
}
|
|
|
|
public function parent()
|
|
{
|
|
return $this->belongsTo(PhotoComment::class, 'parent_comment_id');
|
|
}
|
|
} |