Passed
Push — master ( 96d33b...43186b )
by Gabriel
13:27
created

SubscriptionsTrait::initRelationsPayments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace ByTIC\Payments\Models\Subscriptions;
4
5
use ByTIC\Payments\Models\AbstractModels\HasCustomer\HasCustomerRepository;
6
use ByTIC\Payments\Utility\PaymentsModels;
7
8
/**
9
 * Trait SubscriptionsTrait
10
 * @package ByTIC\Payments\Models\Subscriptions
11
 *
12
 * @method SubscriptionTrait|Subscription getNew
13
 */
14
trait SubscriptionsTrait
15
{
16
    use HasCustomerRepository;
17
    use \ByTIC\Models\SmartProperties\RecordsTraits\HasStatus\RecordsTrait;
18
19
    protected function initRelations()
20
    {
21
        parent::initRelations();
22
        $this->initRelationsPayments();
23
    }
24
25
    protected function initRelationsPayments()
26
    {
27
        $this->initRelationsTransactions();
28
        $this->initRelationsLastTransaction();
29
        $this->initRelationsToken();
30
    }
31
32
    protected function initRelationsTransactions()
33
    {
34
        $this->hasMany('Transactions', ['class' => get_class(PaymentsModels::transactions())]);
35
    }
36
37
    protected function initRelationsLastTransaction()
38
    {
39
        $this->hasOne('LastTransaction', ['class' => get_class(PaymentsModels::transactions())]);
0 ignored issues
show
Bug introduced by
It seems like hasOne() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        $this->/** @scrutinizer ignore-call */ 
40
               hasOne('LastTransaction', ['class' => get_class(PaymentsModels::transactions())]);
Loading history...
40
    }
41
42
    protected function initRelationsToken()
43
    {
44
        $this->hasMany('Token', ['class' => get_class(PaymentsModels::tokens())]);
45
    }
46
47
    /**
48
     * @return string
49
     */
50
    public function getStatusItemsRootNamespace()
51
    {
52
        return 'ByTIC\Payments\Subscriptions\Statuses\\';
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getStatusItemsDirectory()
59
    {
60
        return dirname(dirname(__DIR__))
61
            . DIRECTORY_SEPARATOR . 'Subscriptions'
62
            . DIRECTORY_SEPARATOR . 'Statuses';
63
    }
64
65
    /**
66
     * @return mixed|\Nip\Config\Config
67
     * @throws \Exception
68
     */
69
    protected function generateTable()
70
    {
71
        return config('payments.tables.subscriptions', Subscriptions::TABLE);
72
    }
73
}
74