public function actionDeleteRequirement($user_id, $requirement_id)
 {
     $req = UserRequirement::findOne(['user_id' => $user_id, 'requirement_id' => $requirement_id]);
     if ($req) {
         $req->delete();
     }
     return $this->redirect(['/user/view', 'id' => $user_id]);
 }
 public function addUserRequirement()
 {
     if (!$this->validate()) {
         return false;
     }
     $user = User::findOne($this->user_id);
     if (Requirement::findOne($this->requirement_id === null) || $user === null) {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     foreach ($user->requirements as $current_req) {
         if ($current_req->id == $this->requirement_id) {
             return false;
         }
     }
     $req = new UserRequirement();
     $req->user_id = $this->user_id;
     $req->requirement_id = $this->requirement_id;
     return $req->save();
 }