Rate::source()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
nc 1
nop 0
dl 0
loc 3
c 1
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace Orkhanahmadov\LaravelCurrencylayer\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7
8
/**
9
 * @property int $id
10
 * @property int $source_currency_id
11
 * @property int $target_currency_id
12
 * @property float $rate
13
 * @property int $timestamp
14
 */
15
class Rate extends Model
16
{
17
    /**
18
     * @var string
19
     */
20
    protected $table = 'currencylayer_rates';
21
    /**
22
     * @var bool
23
     */
24
    public $timestamps = false;
25
    /**
26
     * @var array<string>
27
     */
28
    protected $fillable = [
29
        'target_currency_id',
30
        'rate',
31
        'timestamp',
32
    ];
33
    /**
34
     * @var array<string>
35
     */
36
    protected $dates = [
37
        'timestamp',
38
    ];
39
    /**
40
     * @var array<string>
41
     */
42
    protected $casts = [
43
        'rate' => 'float',
44
    ];
45
46
    public function source(): BelongsTo
47
    {
48
        return $this->belongsTo(Currency::class, 'source_currency_id');
49
    }
50
51
    public function target(): BelongsTo
52
    {
53
        return $this->belongsTo(Currency::class, 'target_currency_id');
54
    }
55
}
56