1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Conversation |
4
|
|
|
* |
5
|
|
|
* @package LivePersonInc\LiveEngageLaravel\Models |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace LivePersonInc\LiveEngageLaravel\Models; |
9
|
|
|
|
10
|
|
|
use Illuminate\Database\Eloquent\Model; |
11
|
|
|
use LivePersonInc\LiveEngageLaravel\Collections\AgentParticipants; |
12
|
|
|
use LivePersonInc\LiveEngageLaravel\Collections\ConsumerParticipants; |
13
|
|
|
use LivePersonInc\LiveEngageLaravel\Collections\Transfers; |
14
|
|
|
use LivePersonInc\LiveEngageLaravel\Collections\Transcript; |
15
|
|
|
use LivePersonInc\LiveEngageLaravel\Collections\SDEs; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Conversation class. |
19
|
|
|
* |
20
|
|
|
* @extends Model |
21
|
|
|
*/ |
22
|
|
|
class Conversation extends Model |
23
|
|
|
{ |
24
|
|
|
protected $guarded = []; |
25
|
|
|
|
26
|
|
|
protected $appends = [ |
27
|
|
|
'textTranscript', |
28
|
|
|
]; |
29
|
|
|
|
30
|
2 |
|
public function __construct(array $item) |
31
|
|
|
{ |
32
|
|
|
$init = [ |
33
|
2 |
|
'info' => [], |
34
|
|
|
'visitorInfo' => [], |
35
|
|
|
'campaign' => [], |
36
|
|
|
'transfers' => [], |
37
|
|
|
'agentParticipants' => [], |
38
|
|
|
'consumerParticipants' => [], |
39
|
|
|
'messageRecords' => [], |
40
|
2 |
|
'sdes' => new SDE() |
41
|
|
|
]; |
42
|
|
|
|
43
|
2 |
|
$item = array_merge($init, $item); |
44
|
|
|
|
45
|
2 |
|
$item['info'] = new MessagingInfo((array) $item['info']); |
46
|
2 |
|
$item['visitorInfo'] = new Visitor((array) $item['visitorInfo']); |
47
|
2 |
|
$item['campaign'] = new Campaign((array) $item['campaign']); |
48
|
2 |
|
$item['transfers'] = new Transfers($item['transfers']); |
49
|
2 |
|
$item['agentParticipants'] = new AgentParticipants($item['agentParticipants']); |
50
|
2 |
|
$item['consumerParticipants'] = new ConsumerParticipants($item['consumerParticipants']); |
51
|
2 |
|
$item['messageRecords'] = new Transcript($item['messageRecords'], $item['agentParticipants']); |
52
|
2 |
|
$item['sdes'] = new SDEs($item['sdes']->events ?: []); |
53
|
|
|
|
54
|
2 |
|
parent::__construct($item); |
55
|
2 |
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @codeCoverageIgnore |
59
|
|
|
*/ |
60
|
|
|
public function getTextTranscriptAttribute() |
61
|
|
|
{ |
62
|
|
|
return $this->messageRecords->textTranscript(); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @codeCoverageIgnore |
67
|
|
|
*/ |
68
|
|
|
public function getExportAttribute() |
69
|
|
|
{ |
70
|
|
|
$info = $this->info->attributes; |
|
|
|
|
71
|
|
|
$info['transcript'] = $this->textTranscript; |
72
|
|
|
return ((object)$info); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.