'category/<alias>' => 'category/view',
Url::to(['category/view', 'alias' => $hit->alias]); //так
Yii::$app->urlManager->createUrl(['category/view', 'alias' => $hit->alias]); //или так
public function actionBook() {
$data = $_POST['Book'];
$result = $this->saveBook($data);
}
public function actionTest() {
$data = [
'title' => 'Test title',
'desctiption' => 'Test description'
];
$result = $this->saveBook($data);
}
protected function saveBook($data) {
$model = new Book();
if ($model->load($data, '') && $model->validate()) {
retrun $model->save();
} else {
return false;
}
}
public function getByUserId($id) {
$this->where('user_id = ' . (int) $id);
}
Products::find()->getByUserId(Yii::$app->user->id)->all();