<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class="col-xs-3"><?= $form->field($model, 'text') ?></div>
<div class="col-xs-3"><?= $form->field($model, 'cat') ?></div>
<div class="col-xs-3"><?= $form->field($model, 'status')->dropDownList($model->getStatusList(),['prompt'=>''])
?></div>
<div class="col-xs-3"><?= $form->field($model, 'email') ?></div>
<div class="form-group col-xs-12">
<?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
<?= Html::a(Yii::t('app', 'Создать Запрос'), ['create'], ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
public function actionIndex()
{
$searchModel = new RequestSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
$problems = Problems->find()->with('ProblemsHasOrgan')->all();
foreach($problems->getProblemsHasOrgan->all() as $one)
{
echo $one->problemOrgan->name;
}
RewriteEngine on
# hide files and folders
RedirectMatch 404 /\.git
RedirectMatch 404 /composer\.
RedirectMatch 404 /.bowerrc
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
<?php
defined('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod');
require(__DIR__ . '/../yii/vendor/autoload.php');
require(__DIR__ . '/../yii/vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../yii/common/config/bootstrap.php');
require(__DIR__ . '/../yii/frontend/config/bootstrap.php');
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../yii/common/config/main.php'),
require(__DIR__ . '/../yii/common/config/main-local.php'),
require(__DIR__ . '/../yii/frontend/config/main.php'),
require(__DIR__ . '/../yii/frontend/config/main-local.php')
);
$application = new yii\web\Application($config);
$application->run();
public function getUser()
{
return $this->hasOne(User::className(),['id'=>'user_id']);
}
public function getUserOrg()
{
return $this->hasOne(UserOrg::className(),['org'=>'id']);
}
$service = Service::findOne($id);
// можно так, меньше запросов к бд:
// $service = Service::find()->with(['User','UserOrg'])->where(['id'=>$id])->one();
echo $service->user->username;
echo $servise->user->userOrg->name;
public function beforeAction($event)
{
$data = Yii::$app->cache->get('settings');
if ($data === false) {
$data = $cache->set('settings', $model->getAttributes());
Yii::$app->cache->set('settings', $data, 3600);
}
// как вариант можно записывать в Yii::$app->params
// Yii::$app->params = $data;
return parent::beforeAction($event);
}