fix: resolve PHPStan static analysis warnings

This commit is contained in:
xboard committed 2025-04-14 02:12:42 +08:00
1 parent 9e2f46c688
commit b885e644a8
84 files changed
+2330 -1190

No files matched your search

+31
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;
}
}