Пример #1
0
 /**
  * Creates a new Notificaciones model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new CrearNotificacionForm();
     $model->scenario = CrearNotificacionForm::ESCENARIO_CREAR;
     if ($model->load(Yii::$app->request->post()) && ($notificacion = $model->crear())) {
         Yii::$app->session->setFlash('toasts', 'Se ha enviado la notificación');
         return $this->redirect(['index']);
         return $this->redirect(['view', 'id' => $notificacion->idnotificacion]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #2
0
 /**
  * Envia un mensaje al propietario o interesado
  * Desde el frontend en el detalle del anuncio
  * Se crea una notificacion para el propietario
  * @return bool
  */
 public function enviarMensajePublico()
 {
     $model = new Mensajes();
     $this->scenario = self::ESCENARIO_PUBLICO;
     if ($this->validate()) {
         $model->texto = !empty($this->texto) ? ucfirst($this->texto) : self::TEXTO;
         $model->articulo = $this->articulo;
         $model->usuario = $this->usuario;
         $model->tipo = $this->tipo;
         $model->conversacion = $this->conversacion;
         if ($model->save(false)) {
             //                echo '<pre>';print_r(['',$this->_conversacion->upropietario]);die();
             $notificacion = new CrearNotificacionForm();
             $notificacion->scenario = CrearNotificacionForm::ESCENARIO_CREAR_POR_MENSAJE;
             $notificacion->usuario = $this->_conversacion->propietario;
             $notificacion->tipo = NotificacionesTipo::TIPO_MENSAJE;
             $notificacion->referencia = $model->idmensaje;
             $notificacion->referencia_tipo = Notificaciones::REF_MENSAJE;
             $notificacion->mensaje = strlen($model->texto) > 85 ? substr($model->texto, 0, 85) . '...' : $model->texto;
             $notificacion->leida = Notificaciones::VISTO_NO;
             $notificacion->crear();
             return true;
         }
     }
     return false;
 }
Пример #3
0
 /**
  * Actualizar notificacion para un usuario
  * @param $id
  */
 public function actionActualizar($id)
 {
     $id = !empty($id) ? intval($id) : 1;
     $model = new CrearNotificacionForm();
     $model->scenario = CrearNotificacionForm::ESCENARIO_EDITAR;
     $model->id = $id;
     if ($model->actualizar()) {
         $this->stdout('Se ha actualizado la notificacion a visto', Console::FG_GREEN);
         return;
     }
     $this->stdout("No se ha podido actualizar la notificacion \n", Console::FG_RED);
     return;
 }