mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-03 10:30:51 +08:00
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* App\Models\TicketMessage
|
|
*
|
|
* @property int $id
|
|
* @property int $ticket_id
|
|
* @property int $user_id
|
|
* @property string $message
|
|
* @property \Illuminate\Support\Carbon $created_at
|
|
* @property \Illuminate\Support\Carbon $updated_at
|
|
* @property-read \App\Models\Ticket $ticket 关联的工单
|
|
* @property-read bool $is_me 当前消息是否由工单发起人发送
|
|
*/
|
|
class TicketMessage extends Model
|
|
{
|
|
protected $table = 'v2_ticket_message';
|
|
protected $dateFormat = 'U';
|
|
protected $guarded = ['id'];
|
|
protected $casts = [
|
|
'created_at' => 'timestamp',
|
|
'updated_at' => 'timestamp'
|
|
];
|
|
|
|
protected $appends = ['is_me'];
|
|
|
|
/**
|
|
* 关联的工单
|
|
*/
|
|
public function ticket(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Ticket::class, 'ticket_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 判断消息是否由工单发起人发送
|
|
*/
|
|
public function getIsMeAttribute(): bool
|
|
{
|
|
return $this->ticket->user_id === $this->user_id;
|
|
}
|
|
}
|