function groupBy(array $elements, callable $getUniqueKey) {
$grouped = [];
foreach ($elements as $element) {
$uniqueKey = $getUniqueKey($element);
$grouped[$uniqueKey][] = $element;
}
return $grouped;
}
$groupedByDate = groupBy($app, function($event) {
return date("Y-m-d", strtotime($event['created_at']));
});
$identity = User::findOne(['username' => $username]);
Yii::$app->user->login($identity);
public $authorName;
->select(['t.id', 't.title', 't.description', 'author.username as "authorName"'])
public static function hashPassword($password,$cost=13)
{
self::checkBlowfish();
$salt=self::generateSalt($cost);
$hash=crypt($password,$salt);
if(!is_string($hash) || (function_exists('mb_strlen') ? mb_strlen($hash, '8bit') : strlen($hash))<32)
throw new CException(Yii::t('yii','Internal error while generating hash.'));
return $hash;
}
<?php foreach ($ant->authors as $author) { ?>
<?= $author->author_name ?>
<?php } ?>
$query = Model::find()->where('name LIKE :q')->addParams(['q'=>$q . '%'])->orderBy('name ASC')->all();
<?php $form = ActiveForm::begin([
'enableAjaxValidation' => true,
'validationUrl' => ["site/entry"] // опциональный параметр, указывает метод для валидации. По умолчанию обработчик формы.
]); ?>
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$model->load(Yii::$app->request->post());
return \yii\widgets\ActiveForm::validate($model);
}
все пишут про установку через этот еб**ный composer