$ser_spec = ServiceSpec::find()->where(['specialist_id' => $specialist['id']])->asArray()->all();
$service = Services::find()->where(['id' => $ser_spec['service_id']]);
<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
return [
'id' => 'app-backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log', 'gii', 'debug'],
'defaultRoute' => 'orders/index',
'modules' => [
'gii' => [
'class' => 'yii\gii\Module',
],
'debug' => [
'class' => 'yii\debug\Module',
],
],
'components' => [
'request' => [
'csrfParam' => '_csrf-backend',
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the backend
'name' => 'advanced-backend',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
//
],
],
],
'params' => $params,
];
<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
return [
'id' => 'app-backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log', 'gii', 'debug'],
'defaultRoute' => 'orders/index',
'modules' => [
'gii' => [
'class' => 'yii\gii\Module',
],
'debug' => [
'class' => 'yii\debug\Module',
],
],
'components' => [
'request' => [
'csrfParam' => '_csrf-backend',
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the backend
'name' => 'advanced-backend',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
//
],
],
],
'params' => $params,
];
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use \yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "orders".
*
* @property integer $id
* @property string $created_at
* @property string $updated_at
* @property integer $qty
* @property double $sum
* @property integer $status
* @property string $name
* @property string $email
* @property string $phone
* @property string $adress
*/
class Orders extends ActiveRecord
{
const STATUS_BLOCKED = 1;
const STATUS_ACTIVE = 0;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'orders';
}
public function behaviors(){
return [
[
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
],
// if you're using datetime instead of UNIX timestamp:
'value' => new Expression('NOW()'),
],
];
}
public function rules()
{
return [
[['name', 'email', 'phone', 'adress'], 'required'],
[['created_at', 'updated_at'], 'safe'],
[['qty', 'status', 'sum'], 'integer'],
[['name', 'email', 'phone', 'adress'], 'string', 'max' => 255],
['status', 'default', 'value' => self::STATUS_ACTIVE],
['status', 'in', 'range' => array_keys(self::getStatusesArray())]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => '№',
'created_at' => 'Дата создания',
'updated_at' => 'Дата изменения',
'qty' => 'Кол-во',
'sum' => 'Сумма',
'status' => 'Статус',
'name' => 'Имя',
'email' => 'E-mail',
'phone' => 'Телефон',
'adress' => 'Адрес',
];
}
public function getOrderItems()
{
return $this->hasMany(OrderItems::className(), ['order_id' => 'id']);
}
public function getStatusName()
{
return ArrayHelper::getValue(self::getStatusesArray(), $this->status);
}
public static function getStatusesArray()
{
return [
self::STATUS_ACTIVE => 'Активен',
self::STATUS_BLOCKED => 'Завершён'
];
}
}
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
//['class' => 'yii\grid\SerialColumn'],
'id',
'created_at',
'updated_at',
'qty',
'sum',
[
'attribute' => 'status',
'value' => Html::tag('span',
$model->getStatusName(),
['class' => 'label label-' . ArrayHelper::getValue([0 => 'danger', 1 => 'success'], $model->status)])
],
'name',
'email:email',
'phone',
//'adress',
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Действие',
],
],
]); ?>
Вот так сработало, и теперь так как я и хотел.