class Certification extends ActiveRecord...
{
//...
/**
* Получаем обратную дату окончания действия категории
* @return string
*/
public function getReverseEndDate(): string
{
$date = date_create($this->date_from); //подготавливаем дату для рассчёта срока
$date = date_modify($date, '-'.$this->category->duration_months.'month'); //Вычитаем дату от текущей
return Yii::$app->formatter->asTimestamp($date);
}
public function getValidCategory()
{
return $this->hasOne(Category::className(), ['id' => 'category_id'])
->andWhere(['<=', 'date_from', 'reverseEndDate']);
}
$certifications = Certification::find()
->joinWith(['user', 'profile', 'validCategory'])
->andWhere([User::tableName().'.status' => User::STATUS_ACTIVE])
->andWhere('CONCAT_WS(" ", '.Profile::tableName().'.last_name, '.Profile::tableName().'.name, '.Profile::tableName().'.middle_name) LIKE :search')
->params([':search' => '%' . $search . '%'])
->orderBy([Profile::tableName().'.last_name' => 'SORT_ASC', Profile::tableName().'.name' => 'SORT_ASC'])
->limit(8)
#->isValid() //?? метод из модели CertificationQuery уже не нужен
->all();
'formatter' => [
'class' => 'yii\i18n\Formatter',
'timeZone' => 'Europe/Moscow',
'datetimeFormat'=> 'dd MMMM YYYY HH:mm:ss',
'dateFormat' => 'dd MMMM YYYY',
'timeFormat' => 'HH:mm:ss',
...
],
<?= \Yii::$app->formatter->asDatetime($portfolio['date']);?>
<?= \Yii::$app->formatter->asDatetime($portfolio['date'], 'dd MMMM в HH:mm');?>
phpinfo()
'formatter' => [
...
'locale' => 'uk-UA'
...
],
'components' => [
* 'mailer' => [
* 'class' => 'yii\swiftmailer\Mailer',
* 'transport' => [
* 'class' => 'Swift_SmtpTransport',
* 'host' => 'localhost',
* 'username' => 'username',
* 'password' => 'password',
* 'port' => '587',
* 'encryption' => 'tls',
* ],
* ],
* // ...
* ],