PHP
- 16 ответов
- 0 вопросов
11
Вклад в тег
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();