project column

This commit is contained in:
Kavalar 2023-04-20 02:07:19 +03:00
parent edea2cc3e7
commit 2482ae89f6
24 changed files with 737 additions and 18 deletions

View File

@ -0,0 +1,127 @@
<?php
namespace backend\modules\project\controllers;
use Yii;
use backend\modules\project\models\ProjectColumn;
use backend\modules\project\models\ProjectColumnSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* ProjectColumnController implements the CRUD actions for ProjectColumn model.
*/
class ProjectColumnController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all ProjectColumn models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ProjectColumnSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single ProjectColumn model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new ProjectColumn model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new ProjectColumn();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing ProjectColumn model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing ProjectColumn model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the ProjectColumn model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return ProjectColumn the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = ProjectColumn::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace backend\modules\project\models;
class ProjectColumn extends \common\models\ProjectColumn
{
}

View File

@ -0,0 +1,72 @@
<?php
namespace backend\modules\project\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\project\models\ProjectColumn;
/**
* ProjectColumnSearch represents the model behind the search form of `backend\modules\project\models\ProjectColumn`.
*/
class ProjectColumnSearch extends ProjectColumn
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'project_id', 'status'], 'integer'],
[['title', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = ProjectColumn::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'project_id' => $this->project_id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'status' => $this->status,
]);
$query->andFilterWhere(['like', 'title', $this->title]);
return $dataProvider;
}
}

View File

@ -18,7 +18,7 @@ class ProjectSearch extends Project
public function rules() public function rules()
{ {
return [ return [
[['id','status'], 'integer'], [['id','status', 'owner_id'], 'integer'],
[['name', 'description', 'created_at', 'updated_at'], 'safe'], [['name', 'description', 'created_at', 'updated_at'], 'safe'],
]; ];
} }
@ -61,6 +61,7 @@ class ProjectSearch extends Project
$query->andFilterWhere([ $query->andFilterWhere([
'id' => $this->id, 'id' => $this->id,
'status' => $this->status, 'status' => $this->status,
'owner_id' => $this->owner_id,
'created_at' => $this->created_at, 'created_at' => $this->created_at,
'updated_at' => $this->updated_at, 'updated_at' => $this->updated_at,
]); ]);

View File

@ -0,0 +1,35 @@
<?php
use common\models\Project;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectColumn */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="project-column-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'project_id')->dropDownList(
Project::find()->select(['name', 'id'])->indexBy('id')->column(),
[
'id' => 'project-id',
'placeholder' => 'Выберите',
'prompt' => 'Выберите'
]
) ?>
<?= $form->field($model, 'status')->dropDownList(\common\models\ProjectColumn::getStatus(), ['prompt' => 'Выберите статус']) ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectColumnSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="project-column-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'title') ?>
<?= $form->field($model, 'project_id') ?>
<?= $form->field($model, 'created_at') ?>
<?= $form->field($model, 'updated_at') ?>
<?php // echo $form->field($model, 'status') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectColumn */
$this->title = 'Создать колонку';
$this->params['breadcrumbs'][] = ['label' => 'Колонки проектов', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="project-column-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,47 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\project\models\ProjectColumnSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Колонки проектов';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="project-column-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Создать', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'id',
'title',
[
'attribute' => 'project_id',
'value' => function(\common\models\ProjectColumn $model){
return $model->project->name ?? 'Не задано';
}
],
'created_at',
'updated_at',
[
'attribute' => 'status',
'value' => function (\common\models\ProjectColumn $model) {
return \common\models\ProjectColumn::getStatus()[$model->status] ?? 'Не задано';
}
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectColumn */
$this->title = 'Редактировать колонку: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Колонки проектов', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Редактировать';
?>
<div class="project-column-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,49 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectColumn */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Колонки проектов', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="project-column-view">
<p>
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'title',
[
'attribute' => 'project_id',
'value' => ArrayHelper::getValue($model, 'project.name' ),
],
'created_at',
'updated_at',
[
'attribute' => 'status',
'value' => function (\common\models\ProjectColumn $model) {
return \common\models\ProjectColumn::getStatus()[$model->status] ?? 'Не задано';
}
],
],
]) ?>
</div>

View File

@ -21,6 +21,17 @@ use mihaildev\elfinder\InputFile;
<?= $form->field($model, 'budget')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'budget')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'owner_id')->widget(
Select2::class,
[
'data' => \common\models\UserCard::getListUserWithUserId(),
'options' => ['placeholder' => '...', 'class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
); ?>
<?= $form->field($model, 'company_id')->widget(Select2::class, <?= $form->field($model, 'company_id')->widget(Select2::class,
[ [
'data' => \yii\helpers\ArrayHelper::map(\common\models\Company::find()->all(),'id', 'name'), 'data' => \yii\helpers\ArrayHelper::map(\common\models\Company::find()->all(),'id', 'name'),

View File

@ -41,6 +41,21 @@ $this->params['breadcrumbs'][] = $this->title;
]), ]),
], ],
'budget', 'budget',
[
'attribute' => 'owner_id',
'value' => function (\common\models\Project $model) {
return $model->owner->userCard->fio ?? 'Не задано';
},
'filter' => kartik\select2\Select2::widget([
'model' => $searchModel,
'attribute' => 'owner_id',
'data' => \common\models\UserCard::getListUserWithUserId(),
'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]),
],
//'description:ntext', //'description:ntext',
[ [
'label' => 'Исполнители', 'label' => 'Исполнители',

View File

@ -34,6 +34,12 @@ $this->params['breadcrumbs'][] = $this->title;
'label' => 'Сраница на hh.ru', 'label' => 'Сраница на hh.ru',
'attribute' => 'hh.url' 'attribute' => 'hh.url'
], ],
[
'attribute' => 'owner_id',
'value' => function (\common\models\Project $model) {
return $model->owner->userCard->fio ?? 'Не задано ФИО';
}
],
'description:ntext', 'description:ntext',
'status', 'status',
'created_at', 'created_at',

View File

@ -10,7 +10,7 @@ use yii\db\StaleObjectException;
* This is the model class for table "manager". * This is the model class for table "manager".
* *
* @property int $id * @property int $id
* @property int $user_card_id * @property int $user_id
* *
* @property UserCard $userCard * @property UserCard $userCard
* @property ManagerEmployee[] $managerEmployees * @property ManagerEmployee[] $managerEmployees
@ -31,10 +31,10 @@ class Manager extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['user_card_id'], 'integer'], [['user_id'], 'integer'],
[['user_card_id'], 'required'], [['user_id'], 'required'],
['user_card_id', 'unique', 'message'=>'Уже является менеджером'], ['user_id', 'unique', 'message' => 'Уже является менеджером'],
[['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']], [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_id' => 'id']],
]; ];
} }
@ -45,7 +45,7 @@ class Manager extends \yii\db\ActiveRecord
{ {
return [ return [
'id' => 'ID', 'id' => 'ID',
'user_card_id' => 'Карточка менеджера', 'user_id' => 'Карточка менеджера',
]; ];
} }
@ -55,7 +55,7 @@ class Manager extends \yii\db\ActiveRecord
*/ */
public function beforeDelete() public function beforeDelete()
{ {
foreach ($this->managerEmployees as $employee){ foreach ($this->managerEmployees as $employee) {
$employee->delete(); $employee->delete();
} }
return parent::beforeDelete(); return parent::beforeDelete();
@ -64,9 +64,9 @@ class Manager extends \yii\db\ActiveRecord
/** /**
* @return ActiveQuery * @return ActiveQuery
*/ */
public function getUserCard() public function getUser()
{ {
return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']); return $this->hasOne(User::class, ['id' => 'user_id']);
} }
/** /**

View File

@ -9,7 +9,7 @@ use yii\db\ActiveQuery;
* *
* @property int $id * @property int $id
* @property int $manager_id * @property int $manager_id
* @property int $user_card_id * @property int $employee_id
* *
* @property Manager $manager * @property Manager $manager
* @property UserCard $userCard * @property UserCard $userCard
@ -30,10 +30,10 @@ class ManagerEmployee extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['manager_id', 'user_card_id'], 'required'], [['manager_id', 'employee_id'], 'required'],
[['manager_id'], 'integer'], [['manager_id'], 'integer'],
['user_card_id', 'unique', 'targetAttribute' => ['manager_id', 'user_card_id'], 'message'=>'Этот сотрудник уже закреплён за менеджером'], ['employee_id', 'unique', 'targetAttribute' => ['manager_id', 'user_card_id'], 'message' => 'Этот сотрудник уже закреплён за менеджером'],
[['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']], [['employee_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']],
[['manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']], [['manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']],
]; ];
} }
@ -46,16 +46,16 @@ class ManagerEmployee extends \yii\db\ActiveRecord
return [ return [
'id' => 'ID', 'id' => 'ID',
'manager_id' => 'Менеджер', 'manager_id' => 'Менеджер',
'user_card_id' => 'Карточка работника', 'employee_id' => 'Карточка работника',
]; ];
} }
/** /**
* @return ActiveQuery * @return ActiveQuery
*/ */
public function getUserCard(): ActiveQuery public function getEmployee()
{ {
return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']); return $this->hasOne(User::class, ['id' => 'employee_id']);
} }
/** /**

View File

@ -19,6 +19,7 @@ use yii\helpers\ArrayHelper;
* @property string $budget * @property string $budget
* @property int $company_id * @property int $company_id
* @property int $hh_id * @property int $hh_id
* @property int $owner_id
* *
* @property FieldsValue[] $fieldsValues * @property FieldsValue[] $fieldsValues
* @property Company $company * @property Company $company
@ -59,6 +60,7 @@ class Project extends \yii\db\ActiveRecord
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']], [['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
[['name'], 'string', 'max' => 255], [['name'], 'string', 'max' => 255],
[['budget'], 'string', 'max' => 100], [['budget'], 'string', 'max' => 100],
[['owner_id'], 'integer'],
[['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']], [['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']],
[['hh_id'], 'exist', 'skipOnError' => true, 'targetClass' => Hh::class, 'targetAttribute' => ['hh_id' => 'id']], [['hh_id'], 'exist', 'skipOnError' => true, 'targetClass' => Hh::class, 'targetAttribute' => ['hh_id' => 'id']],
]; ];
@ -79,6 +81,7 @@ class Project extends \yii\db\ActiveRecord
'budget' => 'Бюджет', 'budget' => 'Бюджет',
'company_id' => 'Компания', 'company_id' => 'Компания',
'hh_id' => 'Проект на hh.ru', 'hh_id' => 'Проект на hh.ru',
'owner_id' => 'Владелец проекта',
]; ];
} }
@ -98,6 +101,14 @@ class Project extends \yii\db\ActiveRecord
return $this->hasOne(Company::class, ['id' => 'company_id']); return $this->hasOne(Company::class, ['id' => 'company_id']);
} }
/**
* @return \yii\db\ActiveQuery
*/
public function getOwner()
{
return $this->hasOne(User::class, ['id' => 'owner_id']);
}
/** /**
* @return \yii\db\ActiveQuery * @return \yii\db\ActiveQuery
*/ */

View File

@ -0,0 +1,95 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
/**
* This is the model class for table "project_column".
*
* @property int $id
* @property string $title
* @property int $project_id
* @property string $created_at
* @property string $updated_at
* @property int $status
*
* @property Project $project
*/
class ProjectColumn extends \yii\db\ActiveRecord
{
const STATUS_ACTIVE = 1;
const STATUS_DISABLE = 0;
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'project_column';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['title', 'project_id'], 'required'],
[['project_id', 'status'], 'integer'],
[['created_at', 'updated_at'], 'safe'],
[['title'], 'string', 'max' => 255],
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'title' => 'Название',
'project_id' => 'Проект',
'created_at' => 'Дата создания',
'updated_at' => 'Дата редактирования',
'status' => 'Статус',
];
}
/**
* @return array[]
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
];
}
/**
* @return string[]
*/
public static function getStatus(): array
{
return [
self::STATUS_ACTIVE => 'Активен',
self::STATUS_DISABLE => 'Выключен'
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProject()
{
return $this->hasOne(Project::className(), ['id' => 'project_id']);
}
}

View File

@ -12,6 +12,8 @@ class m230419_100612_drop_user_card_id_column_from_manager_table extends Migrati
*/ */
public function safeUp() public function safeUp()
{ {
$this->dropForeignKey('manager_user_card', 'manager');;
$this->dropColumn('manager', 'user_card_id');
} }
/** /**
@ -19,5 +21,8 @@ class m230419_100612_drop_user_card_id_column_from_manager_table extends Migrati
*/ */
public function safeDown() public function safeDown()
{ {
$this->addColumn('manager', 'user_card_id', $this->integer(11));
$this->addForeignKey('manager_user_card', 'manager', 'user_card_id',
'user_card', 'id');
} }
} }

View File

@ -0,0 +1,42 @@
<?php
use yii\db\Migration;
/**
* Class m230419_214147_add_user_id_column_at_manager_table
*/
class m230419_214147_add_user_id_column_at_manager_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('manager', 'user_id', $this->integer(11));
$this->addForeignKey('manager_user', 'manager', 'user_id', 'user', 'id');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('manager_user', 'manager');
$this->dropColumn('manager', 'user_id');
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m230419_214147_add_user_id_column_at_manager_table cannot be reverted.\n";
return false;
}
*/
}

View File

@ -0,0 +1,34 @@
<?php
use yii\db\Migration;
/**
* Handles dropping columns from table `{{%manager_employee}}`.
*/
class m230419_214500_drop_user_card_id_column_from_manager_employee_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->dropForeignKey('manager_employee_user_card', 'manager_employee');
$this->dropColumn('manager_employee', 'user_card_id');
$this->addColumn('manager_employee', 'employee_id', $this->integer(11));
$this->addForeignKey('employee_user', 'manager_employee', 'employee_id', 'user', 'id');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->addColumn('manager_employee', 'user_card_id', $this->integer(11));
$this->addForeignKey('manager_employee_user_card', 'manager_employee', 'user_card_id',
'user_card', 'id');
$this->dropForeignKey('employee_user', 'manager_employee');
$this->dropColumn('manager_employee', 'employee_id');
}
}

View File

@ -0,0 +1,40 @@
<?php
use yii\db\Migration;
/**
* Class m230419_220233_add_owner_id_column_at_project_table
*/
class m230419_220233_add_owner_id_column_at_project_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('project', 'owner_id', $this->integer());
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('project', 'owner_id');
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m230419_220233_add_owner_id_column_at_project_table cannot be reverted.\n";
return false;
}
*/
}

View File

@ -0,0 +1,35 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%project_column}}`.
*/
class m230419_223851_create_project_column_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%project_column}}', [
'id' => $this->primaryKey(),
'title' => $this->string(255)->notNull(),
'project_id' => $this->integer()->notNull(),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime(),
'status' => $this->integer(1)->defaultValue(1)
]);
$this->addForeignKey('fk_project_column_project', 'project_column', 'project_id', 'project', 'id');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('fk_project_column_project', 'project_column');
$this->dropTable('{{%project_column}}');
}
}

View File

@ -82,7 +82,7 @@ class ProjectController extends ApiController
} }
if (!empty($user_id)) { if (!empty($user_id)) {
$projectIdList = ProjectUser::find()->where(['user_id' => $user_id])->select('project_id')->column(); $projectIdList = ProjectUser::find()->where(['user_id' => $user_id])->select('project_id')->column();
$query = Project::find()->where([ 'IN', 'id', $projectIdList]); $query = Project::find()->where([ 'IN', 'id', $projectIdList])->orWhere(['owner_id' => $user_id]);
} else { } else {
$query = Project::find(); $query = Project::find();
} }

View File

@ -36,6 +36,12 @@ use yii\web\Linkable;
* description="Идентификатор проекта на hh.ru" * description="Идентификатор проекта на hh.ru"
* ), * ),
* @OA\Property( * @OA\Property(
* property="owner_id",
* type="int",
* example="19",
* description="Идентификатор владельца проекта"
* ),
* @OA\Property(
* property="company", * property="company",
* ref="#/components/schemas/Company", * ref="#/components/schemas/Company",
* ), * ),
@ -67,6 +73,11 @@ use yii\web\Linkable;
* example="345343434" * example="345343434"
* ), * ),
* @OA\Property( * @OA\Property(
* property="owner_id",
* type="integer",
* example="19"
* ),
* @OA\Property(
* property="company", * property="company",
* ref="#/components/schemas/Company", * ref="#/components/schemas/Company",
* ), * ),
@ -86,6 +97,7 @@ class Project extends \common\models\Project
'hh_id' => function() { 'hh_id' => function() {
return $this->hh; return $this->hh;
}, },
'owner_id',
'company' => function() { 'company' => function() {
return $this->company; return $this->company;
} }