1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | namespace Gewaer\Models; |
||
5 | |||
6 | use Phalcon\Di; |
||
7 | |||
8 | class UserCompanyApps extends \Baka\Auth\Models\UserCompanyApps |
||
9 | { |
||
10 | /** |
||
11 | * |
||
12 | * @var integer |
||
13 | */ |
||
14 | public $company_id; |
||
15 | |||
16 | /** |
||
17 | * |
||
18 | * @var integer |
||
19 | */ |
||
20 | public $apps_id; |
||
21 | |||
22 | /** |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | public $stripe_id; |
||
27 | |||
28 | /** |
||
29 | * |
||
30 | * @var integer |
||
31 | */ |
||
32 | public $subscriptions_id; |
||
33 | |||
34 | /** |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | public $created_at; |
||
39 | |||
40 | /** |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | public $updated_at; |
||
45 | |||
46 | /** |
||
47 | * |
||
48 | * @var integer |
||
49 | */ |
||
50 | public $is_deleted; |
||
51 | |||
52 | /** |
||
53 | * Initialize method for model. |
||
54 | */ |
||
55 | 2 | public function initialize() |
|
56 | { |
||
57 | 2 | parent::initialize(); |
|
58 | |||
59 | 2 | $this->belongsTo( |
|
60 | 2 | 'company_id', |
|
61 | 2 | 'Gewaer\Models\Companies', |
|
62 | 2 | 'id', |
|
63 | 2 | ['alias' => 'company'] |
|
64 | ); |
||
65 | |||
66 | 2 | $this->belongsTo( |
|
67 | 2 | 'apps_id', |
|
68 | 2 | 'Gewaer\Models\Apps', |
|
69 | 2 | 'id', |
|
70 | 2 | ['alias' => 'app'] |
|
71 | ); |
||
72 | |||
73 | 2 | $this->setSource('user_company_apps'); |
|
74 | 2 | } |
|
75 | |||
76 | /** |
||
77 | * Returns table name mapped in the model. |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | 2 | public function getSource() : string |
|
82 | { |
||
83 | 2 | return 'user_company_apps'; |
|
84 | } |
||
85 | |||
86 | /** |
||
87 | * Get the current company app |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | public static function getCurrentApp(): UserCompanyApps |
||
92 | { |
||
93 | return self::findFirst([ |
||
1 ignored issue
–
show
Bug
Best Practice
introduced
by
![]() |
|||
94 | 'conditions' => 'company_id = ?0 and apps_id = ?1', |
||
95 | 'bind' => [Di::getDefault()->getUserData()->defaultCompany->getId(), Di::getDefault()->getApp()->getId()] |
||
96 | ]); |
||
97 | } |
||
98 | } |
||
99 |