Completed
Push — master ( d5595a...9bb41e )
by Orkhan
08:19
created

Payment::getSuccessfulAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Orkhanahmadov\LaravelGoldenpay\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * Class Payment
9
 * @package Orkhanahmadov\LaravelGoldenpay\Models
10
 *
11
 * @property int $id
12
 * @property string $payment_key
13
 * @property int $amount
14
 * @property string $card_type
15
 * @property string $language
16
 * @property string $description
17
 * @property int $status
18
 * @property string $message
19
 * @property string $reference_number
20
 * @property string $card_number
21
 * @property \Carbon\Carbon $payment_date
22
 * @property int $checks
23
 * @property \Carbon\Carbon $created_at
24
 * @property \Carbon\Carbon $updated_at
25
 * @property-read float|int $formatted_amount
26
 * @property-read bool $successful
27
 * @method static Payment first()
28
 */
29
class Payment extends Model
30
{
31
    protected $guarded = [
32
        'status',
33
    ];
34
35
    protected $dates = [
36
        'payment_date',
37
    ];
38
39
    protected $hidden = [
40
        'card_number',
41
    ];
42
43
    protected $casts = [
44
        'amount' => 'int',
45
        'status' => 'int',
46
        'checks' => 'int',
47
    ];
48
49
    public function __construct(array $attributes = [])
50
    {
51
        parent::__construct($attributes);
52
53
        $this->setTable(config('goldenpay.table_name'));
54
    }
55
56
    public function getSuccessfulAttribute(): bool
57
    {
58
        return $this->status === 1;
59
    }
60
61
    public function getFormattedAmountAttribute()
62
    {
63
        return $this->amount / 100;
64
    }
65
}
66