public function afterSave($insert, $changedAttributes)
{
if ($insert && $this->role_id === 2) {
$profile = $this->module->manager->createProfile([
'user_id' => $this->id,
'gravatar_email' => $this->email
]);
$profile->save(false);
}
parent::afterSave($insert, $changedAttributes);
}
class UpdateStatusMark extends Model {
// ....
public function save() {
// ищем все связанные модели
$transaction = Yii::$app->getDb()->beginTransaction();
try {
$carMark->save();
$carModel->save();
$carSerie->save();
$transaction->commit();
} catch($exception) {
$transaction->rollback();
// пишем в лог
// throw
}
}
}
#!/bin/bash
/ПУТЬ ДО ПРОЕКТА/yii test/index
* * * * * /bin/bash /ПУТЬ ДО ПРОЕКТА/scripts/НАЗВАНИЕ ФАЙЛА
public function getMoves()
{
return $this->hasMany(Move::className(), ['id' => 'move_id'])
->viaTable('pattern_moves', ['pattern_id' => 'id'])->orderBy('order_num ASC');
}
http://test.com/article/description?aID=323&aTitle=teaser+of+this+article
aID=323&aTitle=teaser+of+this+article
это query параметры.'article/description' => 'article/description'
public function actionDescription($aID, $aTitle, $something, $else) {}
public function actionDescription($aID, $aTitle = null, $something = 'default', $else = 1) {}
->andWhere(['not', ['price2' => null]])
или
->andWhere(['is not', 'price2', null])
$categories = Category::find()
->where(['>=', 'lft', $model->lft])
->andWhere(['<=', 'rgt', $model->rgt])
->with('products')
->all();
public function getProducts()
{
return $this->hasMany(Product::className(), ['category_id' => 'id']);
}