Advertisement
Guest User

Untitled

a guest
Oct 11th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.49 KB | None | 0 0
  1. <?php
  2.  
  3. namespace common\models;
  4.  
  5. use Yii;
  6.  
  7. /**
  8.  * This is the model class for table "post".
  9.  *
  10.  * @property string $id_post
  11.  * @property string $id_categoryFK
  12.  * @property string $id_user
  13.  * @property string $content
  14.  * @property string $Create_at
  15.  *
  16.  * @property Category $idCategoryFK
  17.  * @property User $idUser
  18.  */
  19. class Post extends \yii\db\ActiveRecord
  20. {
  21.     /**
  22.      * @inheritdoc
  23.      */
  24.     public static function tableName()
  25.     {
  26.         return 'post';
  27.     }
  28.  
  29.  
  30.     public function beforeValidate()
  31.     {
  32.  
  33.     }
  34.  
  35.     public function rules()
  36.     {
  37.         return [
  38.             [['id_categoryFK', 'id_user'], 'integer'],
  39.             [['content', 'Create_at'], 'required'],
  40.             [['Create_at'], 'safe'],
  41.             [['content'], 'string', 'max' => 1000],
  42.         ];
  43.     }
  44.  
  45.     /**
  46.      * @inheritdoc
  47.      */
  48.     public function attributeLabels()
  49.     {
  50.         return [
  51.             'id_post' => 'Id Post',
  52.             'id_categoryFK' => 'Category',
  53.             'id_user' =>  'User',
  54.             'content' => 'Content',
  55.             'Create_at' => 'Create At',
  56.         ];
  57.     }
  58.  
  59.     /**
  60.      * @return \yii\db\ActiveQuery
  61.      */
  62.     public function getIdCategoryFK()
  63.     {
  64.         return $this->hasOne(Category::className(), ['id_category' => 'id_categoryFK']);
  65.     }
  66.  
  67.     /**
  68.      * @return \yii\db\ActiveQuery
  69.      */
  70.     public function getIdUser()
  71.     {
  72.         return $this->hasOne(User::className(), ['id' => 'id_user']);
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement