$this->name,
);
}
public function username(): Attribute
{
return new Attribute(
get:fn () => $this->email,
);
}
public function statusBadge(): Attribute
{
return new Attribute(function(){
$html = '';
if($this->status == Status::TICKET_OPEN){
$html = ''.trans("Open").'';
}
elseif($this->status == Status::TICKET_ANSWER){
$html = ''.trans("Answered").'';
}
elseif($this->status == Status::TICKET_REPLY){
$html = ''.trans("Customer Reply").'';
}
elseif($this->status == Status::TICKET_CLOSE){
$html = ''.trans("Closed").'';
}
return $html;
});
}
public function user()
{
return $this->belongsTo(User::class);
}
public function supportMessage(){
return $this->hasMany(SupportMessage::class);
}
public function scopePending($query){
return $query->whereIn('status', [Status::TICKET_OPEN,Status::TICKET_REPLY]);
}
public function scopeClosed($query){
return $query->where('status',Status::TICKET_CLOSE);
}
public function scopeAnswered($query){
return $query->where('status',Status::TICKET_ANSWER);
}
}