forked from EckmarCommunity/Eckmar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddress.php
65 lines (53 loc) · 1.15 KB
/
Address.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
<?php
namespace App;
use App\Traits\Uuids;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Represents the instance of the coin address for any user
* Can be any Coin that is supported in the config
*
* Class Address
* @package App
*/
class Address extends Model
{
use Uuids;
protected $keyType = 'string';
protected $primaryKey = 'id';
public $incrementing = false;
public static function label($coinName)
{
if($coinName=='btcm')
return 'btc pubkey';
return $coinName;
}
/**
* Relationship with the user
*/
public function user()
{
return $this -> belongsTo(\App\User::class, 'user_id', 'id');
}
/**
* Fix for Bitcoin multisig
*
* @param $coin
* @return string
*/
public function getCoinAttribute($coin)
{
if($coin=='btcm')
return 'btc pubkey';
return $coin;
}
/**
* String how long was passed since adding address
*
* @return string
*/
public function getAddedAgoAttribute()
{
return Carbon::parse($this -> created_at) -> diffForHumans();
}
}