mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 20:17:32 +08:00
fix(admin): correct ticket message bubble alignment in admin panel
This commit is contained in:
@@ -17,7 +17,7 @@ class MessageResource extends JsonResource
|
||||
return [
|
||||
"id" => $this['id'],
|
||||
"ticket_id" => $this['ticket_id'],
|
||||
"is_me" => $this['is_me'],
|
||||
"is_me" => $this['is_from_user'],
|
||||
"message" => $this["message"],
|
||||
"created_at" => $this['created_at'],
|
||||
"updated_at" => $this['updated_at']
|
||||
|
||||
@@ -15,7 +15,8 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @property \Illuminate\Support\Carbon $created_at
|
||||
* @property \Illuminate\Support\Carbon $updated_at
|
||||
* @property-read \App\Models\Ticket $ticket 关联的工单
|
||||
* @property-read bool $is_me 当前消息是否由工单发起人发送
|
||||
* @property-read bool $is_from_user 消息是否由工单发起人发送
|
||||
* @property-read bool $is_from_admin 消息是否由管理员发送
|
||||
*/
|
||||
class TicketMessage extends Model
|
||||
{
|
||||
@@ -27,7 +28,7 @@ class TicketMessage extends Model
|
||||
'updated_at' => 'timestamp'
|
||||
];
|
||||
|
||||
protected $appends = ['is_me'];
|
||||
protected $appends = ['is_from_user', 'is_from_admin'];
|
||||
|
||||
/**
|
||||
* 关联的工单
|
||||
@@ -40,8 +41,16 @@ class TicketMessage extends Model
|
||||
/**
|
||||
* 判断消息是否由工单发起人发送
|
||||
*/
|
||||
public function getIsMeAttribute(): bool
|
||||
public function getIsFromUserAttribute(): bool
|
||||
{
|
||||
return $this->ticket->user_id === $this->user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断消息是否由管理员发送
|
||||
*/
|
||||
public function getIsFromAdminAttribute(): bool
|
||||
{
|
||||
return $this->ticket->user_id !== $this->user_id;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user