bakaphp /
phalcon-api
| 1 | <?php |
||
| 2 | declare(strict_types=1); |
||
| 3 | |||
| 4 | namespace Gewaer\Models; |
||
| 5 | |||
| 6 | use Phalcon\Validation; |
||
| 7 | use Phalcon\Validation\Validator\PresenceOf; |
||
| 8 | |||
| 9 | class Companies extends \Baka\Auth\Models\Companies |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * |
||
| 13 | * @var integer |
||
| 14 | */ |
||
| 15 | public $id; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | public $name; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | public $profile_image; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | public $website; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * |
||
| 37 | * @var integer |
||
| 38 | */ |
||
| 39 | public $users_id; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * |
||
| 43 | * @var string |
||
| 44 | */ |
||
| 45 | public $created_at; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * |
||
| 49 | * @var string |
||
| 50 | */ |
||
| 51 | public $updated_at; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * |
||
| 55 | * @var integer |
||
| 56 | */ |
||
| 57 | public $is_deleted; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Initialize method for model. |
||
| 61 | */ |
||
| 62 | public function initialize() |
||
| 63 | { |
||
| 64 | parent::initialize(); |
||
| 65 | |||
| 66 | $this->setSource('companies'); |
||
| 67 | |||
| 68 | $this->belongsTo( |
||
| 69 | 'users_id', |
||
| 70 | 'Ahorrando\Models\Users', |
||
| 71 | 'id', |
||
| 72 | ['alias' => 'user'] |
||
| 73 | ); |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Model validation |
||
| 78 | * |
||
| 79 | * @return void |
||
| 80 | */ |
||
| 81 | public function validation() |
||
| 82 | { |
||
| 83 | $validator = new Validation(); |
||
| 84 | |||
| 85 | $validator->add( |
||
| 86 | 'name', |
||
| 87 | new PresenceOf([ |
||
| 88 | 'model' => $this, |
||
| 89 | 'required' => true, |
||
| 90 | ]) |
||
| 91 | ); |
||
| 92 | |||
| 93 | return $this->validate($validator); |
||
|
1 ignored issue
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 94 | } |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Returns table name mapped in the model. |
||
| 98 | * |
||
| 99 | * @return string |
||
| 100 | */ |
||
| 101 | public function getSource() : string |
||
| 102 | { |
||
| 103 | return 'companies'; |
||
| 104 | } |
||
| 105 | } |
||
| 106 |