Completed
Push — master ( 7b333d...72ce26 )
by Andrii
04:12
created

Purse::getFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * Finance module for HiPanel
5
 *
6
 * @link      https://github.com/hiqdev/hipanel-module-finance
7
 * @package   hipanel-module-finance
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hipanel\modules\finance\models;
13
14
use hipanel\models\File;
15
use hipanel\modules\client\models\Contact;
16
use Yii;
17
18
class Purse extends \hipanel\base\Model
19
{
20
    use \hipanel\base\ModelTrait;
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function rules()
26
    {
27
        return [
28
            [['id', 'client_id', 'seller_id'],      'integer'],
29
            [['client', 'seller'],                  'safe'],
30
            [['provided_services'],                 'safe'],
31
            [['contact_id', 'requisite_id'],        'integer'],
32
            [['currency_id'],                       'integer'],
33
            [['currency'],                          'safe'],
34
            [['no'],                                'integer'],
35
            [['credit', 'balance'],                 'number'],
36
37
            [['month'],                             'date', 'on' => 'update-monthly-invoice'],
38
        ];
39
    }
40
41
    public function getFiles()
42
    {
43
        return $this->hasMany(File::class, ['object_id' => 'id']);
44
    }
45
46
    public function getContact()
47
    {
48
        return $this->hasOne(Contact::class, ['id' => 'contact_id']);
49
    }
50
51
    public function getRequisite()
52
    {
53
        return $this->hasOne(Contact::class, ['id' => 'requisite_id']);
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function attributeLabels()
60
    {
61
        return $this->mergeAttributeLabels([
62
            'provided_services' => Yii::t('hipanel:finance', 'Provided services'),
63
            'currency'          => Yii::t('hipanel:finance', 'Currency'),
64
            'invoices'          => Yii::t('hipanel:finance', 'Invoices'),
65
        ]);
66
    }
67
}
68