Commit 10899280b881356c47d9eb78598825d1346ec476

Authored by alex
1 parent 43f8a504

customer add create_at column

common/models/Customer.php
@@ -4,6 +4,8 @@ @@ -4,6 +4,8 @@
4 4
5 use Yii; 5 use Yii;
6 use yii\helpers\FileHelper; 6 use yii\helpers\FileHelper;
  7 + use yii\behaviors\TimestampBehavior;
  8 +
7 9
8 /** 10 /**
9 * This is the model class for table "customer". 11 * This is the model class for table "customer".
@@ -47,6 +49,9 @@ @@ -47,6 +49,9 @@
47 * 49 *
48 * @property integer $working_lang 50 * @property integer $working_lang
49 * @property string $post_address ==> официальный почтовый адрес 51 * @property string $post_address ==> официальный почтовый адрес
  52 + *
  53 + * @property integer $created_at
  54 + *
50 */ 55 */
51 class Customer extends \yii\db\ActiveRecord 56 class Customer extends \yii\db\ActiveRecord
52 { 57 {
@@ -75,8 +80,21 @@ @@ -75,8 +80,21 @@
75 { 80 {
76 return 'customer'; 81 return 'customer';
77 } 82 }
78 -  
79 - /** 83 +
  84 +
  85 +
  86 + public function behaviors()
  87 + {
  88 + return [
  89 + [
  90 + 'class' => TimestampBehavior::className(),
  91 + 'updatedAtAttribute' => false,
  92 + ],
  93 + ];
  94 + }
  95 +
  96 +
  97 + /**
80 * {@inheritdoc} 98 * {@inheritdoc}
81 */ 99 */
82 public function rules() 100 public function rules()
console/migrations/m180912_090212_customer_add_update_at_column.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Class m180912_090212_customer_add_update_at_column
  7 + */
  8 +class m180912_090212_customer_add_update_at_column extends Migration
  9 +{
  10 + public function up()
  11 + {
  12 + $this->addColumn('customer',
  13 + 'created_at',
  14 + $this->integer());
  15 + }
  16 +
  17 + public function down()
  18 + {
  19 + $this->dropColumn('customer','created_at');
  20 + }
  21 +
  22 +}