|
- <?php
-
-
-
- namespace common\models;
-
- use Yii;
- use common\components\ActiveRecordCommon;
-
-
- class UserProducer extends ActiveRecordCommon
- {
-
-
-
- public static function tableName()
- {
- return 'user_producer';
- }
-
-
-
- public function rules()
- {
- return [
- [['id_user', 'id_producer'], 'required'],
- [['id_user', 'id_producer', 'product_price_percent'], 'integer'],
- [['active', 'bookmark', 'credit_active'], 'boolean'],
- [['credit', 'product_price_percent'], 'double'],
- ];
- }
-
-
-
- public function attributeLabels()
- {
- return [
- 'id_user' => 'Utilisateur',
- 'id_producer' => 'Producteur',
- 'active' => 'Actif',
- 'bookmark' => 'Favoris',
- 'credit_active' => 'Crédit',
- 'product_price_percent' => 'Prix produits : pourcentage'
- ];
- }
-
- public function getProducer()
- {
- return $this->hasOne(Producer::className(), ['id' => 'id_producer']);
- }
-
- public function getUser()
- {
- return $this->hasOne(User::className(), ['id' => 'id_user']);
- }
-
-
-
- public static function defaultOptionsSearch()
- {
- return [
- 'with' => [],
- 'join_with' => [],
- 'orderby' => '',
- 'attribute_id_producer' => 'user_producer.id_producer'
- ];
- }
-
- }
|