You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
60 lines
1.3 KiB
<?php
|
|
|
|
namespace App\Entities\Projects;
|
|
|
|
use App\Entities\Users\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Issue extends Model
|
|
{
|
|
protected $fillable = [
|
|
'project_id', 'title', 'body', 'priority_id', 'pic_id', 'creator_id',
|
|
];
|
|
|
|
public function project()
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
public function pic()
|
|
{
|
|
return $this->belongsTo(User::class)->withDefault(['name' => __('issue.no_pic')]);
|
|
}
|
|
|
|
public function creator()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function getPriorityAttribute()
|
|
{
|
|
return Priority::getNameById($this->priority_id);
|
|
}
|
|
|
|
public function getPriorityLabelAttribute()
|
|
{
|
|
$classColor = Priority::getColorById($this->priority_id);
|
|
|
|
return '<span class="label label-'.$classColor.'">'.$this->priority.'</span>';
|
|
}
|
|
|
|
public function getStatusAttribute()
|
|
{
|
|
return IssueStatus::getNameById($this->status_id);
|
|
}
|
|
|
|
public function getStatusLabelAttribute()
|
|
{
|
|
return '<span class="badge">'.$this->status.'</span>';
|
|
}
|
|
|
|
/**
|
|
* Issue has many comments relation.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
|
*/
|
|
public function comments()
|
|
{
|
|
return $this->morphMany(Comment::class, 'commentable');
|
|
}
|
|
}
|