guild/backend/modules/balance/models/Balance.php

51 lines
1.3 KiB
PHP
Raw Normal View History

2019-06-21 18:05:58 +03:00
<?php
namespace backend\modules\balance\models;
use common\models\FieldsValue;
2019-06-25 12:37:09 +03:00
use common\models\FieldsValueNew;
2019-06-21 18:05:58 +03:00
use common\models\ProjectUser;
use yii\helpers\ArrayHelper;
class Balance extends \common\models\Balance
{
2019-06-25 12:37:09 +03:00
public $fields;
2019-06-21 18:05:58 +03:00
public function init()
{
parent::init();
2019-06-25 12:37:09 +03:00
$fieldValue = FieldsValueNew::find()
2019-06-21 18:05:58 +03:00
->where(
[
2019-06-25 12:37:09 +03:00
//'balance_id' => \Yii::$app->request->get('id'),
'item_id' => \Yii::$app->request->get('id'),
'item_type' => FieldsValueNew::TYPE_BALANCE,
2019-06-21 18:05:58 +03:00
])
->all();
$array = [];
if (!empty($fieldValue)) {
foreach ($fieldValue as $item) {
array_push($array, ['field_id' => $item->field_id, 'value' => $item->value, 'order' => $item->order]);
}
$this->fields = $array;
} else {
$this->fields = [
[
'field_id' => null,
'value' => null,
'order' => null,
],
];
}
2019-06-25 12:37:09 +03:00
// $user = ArrayHelper::getColumn(ProjectUser::find()->where(['project_id' => \Yii::$app->request->get('id')])->all(),
// 'card_id');
//
// if (!empty($user)) {
// $this->user = $user;
//
// }
2019-06-21 18:05:58 +03:00
}
}