fix: resolve PHPStan static analysis warnings

This commit is contained in:
xboard
2025-05-07 19:48:19 +08:00
parent db235c10e8
commit 97e7ffccae
86 changed files with 2335 additions and 1206 deletions

View File

@@ -3,7 +3,20 @@
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';
@@ -13,4 +26,22 @@ class TicketMessage extends Model
'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;
}
}