Как изменить статус доступного ресурса в базе данных в yii2 - PullRequest
0 голосов
/ 21 апреля 2020

Я хочу, чтобы мои пользователи знали о наличии книги в базе данных перед заимствованием. Ниже мой контроллер.

public function actionBorrow($book_id){
    // echo "here we are in the Borow Controller";
    $model= new Books();
     if ($model->load(Yii::$app->request->post())){
    //here we need to find the book not create a new one
    $model=Books::find()->where(['book_id'=>$book_id])->one();
    //here we will change the status of the book
}
    $model->status=1;
    if($model->save()){
      return $this-> render('create',['model'=>$model,]);
    }else{
        echo "ovyo kabisa";
    }
    //we will redirect the user to your desired view
    //so now we need to add $id to the borrow method
}
...