Compare commits

..

No commits in common. "a3d9b8c4b041c39ac96b66290a6e78d561b8fdae" and "7694c40a68b2fc3f7b0d6c931f60ec9413856f74" have entirely different histories.

3 changed files with 5 additions and 65 deletions

View File

@ -1,61 +0,0 @@
<?php
use yii\db\Migration;
use yii\db\Schema;
class m0000000_init extends Migration
{
public function safeUp()
{
$this->createTable('user', [
'id' => Schema::TYPE_PK,
'name' => Schema::TYPE_TEXT . ' NOT NULL',
'login' => Schema::TYPE_TEXT . ' NOT NULL',
'phone' => Schema::TYPE_TEXT . ' NOT NULL',
'avatar' => Schema::TYPE_TEXT,
'website' => Schema::TYPE_TEXT,
'passHash' => Schema::TYPE_TEXT,
'accessToken' => Schema::TYPE_TEXT
]);
$this->createTable('materials', [
'id' => Schema::TYPE_PK,
'title' => Schema::TYPE_TEXT . ' NOT NULL',
'content' => Schema::TYPE_TEXT . ' NOT NULL',
'blog_id' => Schema::TYPE_BIGINT,
]);
$this->createTable('companies', [
'id' => Schema::TYPE_PK,
'title' => Schema::TYPE_TEXT . ' NOT NULL',
'website' => Schema::TYPE_TEXT . ' NOT NULL',
'address' => Schema::TYPE_TEXT . ' NOT NULL',
'blog_id' => Schema::TYPE_BIGINT,
]);
$this->createTable('blogs', [
'id' => Schema::TYPE_PK
]);
$this->createTable('subscriptions', [
'user_id' => Schema::TYPE_BIGINT . ' NOT NULL',
'blog_id' => Schema::TYPE_BIGINT . ' NOT NULL',
]);
$this->createTable('comments', [
'user_id' => Schema::TYPE_BIGINT . ' NOT NULL',
'material_id' => Schema::TYPE_BIGINT . ' NOT NULL',
'content' => Schema::TYPE_TEXT . ' NOT NULL',
]);
}
public function safeDown()
{
$this->dropTable('user');
$this->dropTable('materials');
$this->dropTable('companies');
$this->dropTable('blogs');
$this->dropTable('subscriptions');
$this->dropTable('comments');
}
}

View File

@ -5,6 +5,8 @@ namespace app\models;
class Blogs extends \yii\db\ActiveRecord
{
public $id;
public $user_id;
public $company_id;
/**
* {@inheritDoc}
@ -19,12 +21,12 @@ class Blogs extends \yii\db\ActiveRecord
public function getUser()
{
return $this->hasOne(User::class, [ 'blog_id' => 'id' ]);
return $this->hasOne(User::class, [ 'id' => 'user_id' ]);
}
public function getCompany()
{
return $this->hasOne(Companies::class, [ 'blog_id' => 'id' ]);
return $this->hasOne(Companies::class, [ 'id' => 'company_id' ]);
}
/**

View File

@ -8,7 +8,6 @@ class Companies extends \yii\db\ActiveRecord
public $title;
public $website;
public $address;
public $blog_id;
/**
* {@inheritDoc}
@ -18,7 +17,7 @@ class Companies extends \yii\db\ActiveRecord
return [
[['id', 'title', 'website', 'address'], 'required'],
[['title', 'website', 'address'], 'string'],
[['id', 'blog_id'], 'integer'],
[['id'], 'integer'],
];
}