• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LeTraceurSnorkLibrary / MessSaga / 23899407418

02 Apr 2026 12:02PM UTC coverage: 30.548% (-1.1%) from 31.674%
23899407418

push

github

web-flow
feat: add s3 as storage

39 of 155 new or added lines in 14 files covered. (25.16%)

4 existing lines in 4 files now uncovered.

457 of 1496 relevant lines covered (30.55%)

0.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/Models/Message.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\Models;
6

7
use App\Models\Concerns\HasEncryptedAttributes;
8
use Illuminate\Database\Eloquent\Factories\HasFactory;
9
use Illuminate\Database\Eloquent\Model;
10
use Illuminate\Database\Eloquent\Relations\BelongsTo;
11

12
/**
13
 * Абстрактный базовый класс для всех типов сообщений мессенджеров.
14
 * Содержит общие поля и методы, специфичные поля определяются в дочерних классах.
15
 */
16
abstract class Message extends Model
17
{
18
    use HasFactory;
19
    use HasEncryptedAttributes;
20

21
    /**
22
     * @inheritdoc
23
     *
24
     *  Базовые fillable поля, общие для всех типов сообщений.
25
     *  Дочерние классы могут расширять этот массив.
26
     */
27
    protected $fillable = [
28
        'conversation_id',
29
        'external_id',
30
        'sender_name',
31
        'sender_external_id',
32
        'sent_at',
33
        'text',
34
        'dedup_hash',
35
        'message_type',
36
        'raw',
37
        'media_attachment_id',
38
    ];
39

40
    /**
41
     * @inheritdoc
42
     *
43
     * Базовые casts, общие для всех типов сообщений.
44
     * Дочерние классы могут расширять этот массив.
45
     */
46
    protected $casts = [
47
        'raw'     => 'array',
48
        'sent_at' => 'datetime',
49
    ];
50

51
    /**
52
     * Отношение к переписке.
53
     *
54
     * @return BelongsTo
55
     */
56
    public function conversation(): BelongsTo
57
    {
58
        return $this->belongsTo(Conversation::class);
×
59
    }
60

61
    /**
62
     * @return BelongsTo
63
     */
64
    public function mediaAttachment(): BelongsTo
65
    {
66
        return $this->belongsTo(MediaAttachment::class, 'media_attachment_id');
×
67
    }
68

69
    /**
70
     * @inheritdoc
71
     */
72
    protected static function booted(): void
73
    {
74
        static::deleting(function (Message $message): void {
×
75
            if ($message->media_attachment_id !== null) {
×
NEW
76
                MediaAttachment::query()
×
NEW
77
                    ->whereKey($message->media_attachment_id)
×
NEW
78
                    ->first()
×
NEW
79
                    ?->delete();
×
80
            }
81
        });
×
82
    }
83

84
    /**
85
     * @inheritdoc
86
     */
87
    protected function getEncryptedAttributes(): array
88
    {
89
        return ['text'];
×
90
    }
91
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc