bakaphp /
phalcon-api
| 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 $companies_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 | 5 | public function initialize() |
|
| 56 | { |
||
| 57 | 5 | parent::initialize(); |
|
| 58 | |||
| 59 | 5 | $this->belongsTo( |
|
| 60 | 5 | 'companies_id', |
|
| 61 | 5 | 'Gewaer\Models\Companies', |
|
| 62 | 5 | 'id', |
|
| 63 | 5 | ['alias' => 'company'] |
|
| 64 | ); |
||
| 65 | |||
| 66 | 5 | $this->belongsTo( |
|
| 67 | 5 | 'apps_id', |
|
| 68 | 5 | 'Gewaer\Models\Apps', |
|
| 69 | 5 | 'id', |
|
| 70 | 5 | ['alias' => 'app'] |
|
| 71 | ); |
||
| 72 | |||
| 73 | 5 | $this->setSource('user_company_apps'); |
|
| 74 | 5 | } |
|
| 75 | |||
| 76 | /** |
||
| 77 | * Returns table name mapped in the model. |
||
| 78 | * |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | 5 | public function getSource() : string |
|
| 82 | { |
||
| 83 | 5 | return 'user_company_apps'; |
|
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Get the current company app |
||
| 88 | * |
||
| 89 | * @return void |
||
| 90 | */ |
||
| 91 | 2 | public static function getCurrentApp(): UserCompanyApps |
|
| 92 | { |
||
| 93 | 2 | return self::findFirst([ |
|
|
1 ignored issue
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 94 | 2 | 'conditions' => 'companies_id = ?0 and apps_id = ?1', |
|
| 95 | 2 | 'bind' => [Di::getDefault()->getUserData()->defaultCompany->getId(), Di::getDefault()->getApp()->getId()] |
|
| 96 | ]); |
||
| 97 | } |
||
| 98 | } |
||
| 99 |