forked from EckmarCommunity/Eckmar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisputeMessage.php
66 lines (57 loc) · 1.29 KB
/
DisputeMessage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace App;
use App\Traits\Uuids;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class DisputeMessage extends Model
{
use Uuids;
protected $primaryKey = 'id';
protected $keyType = 'string';
public $incrementing = false;
/**
* \App\Dispute instance
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function dispute()
{
return $this -> belongsTo(\App\Dispute::class, 'dispute_id');
}
/**
* Set dispute of this message
*
* @param Dispute $dispute
*/
public function setDispute(Dispute $dispute)
{
$this -> dispute_id = $dispute -> id;
}
/**
* Set author of the message
*
* @param User $author
*/
public function setAuthor(User $author)
{
$this -> author_id = $author -> id;
}
/**
* Return author of the purchase
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function author()
{
return $this -> hasOne(\App\User::class, 'id', 'author_id');
}
/**
* Past time since message is created
*
* @return string
*/
public function getTimeAgoAttribute()
{
return Carbon::parse($this -> created_at) -> diffForHumans();
}
}