NotificacionController.php 734 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\components;
  3. use app\models\Notificacion;
  4. use yii\console\Controller;
  5. class NotificacionController extends Controller {
  6. public $debug = true;
  7. public function stdout($texto) {
  8. if ($this->debug) {
  9. parent::stdout($texto);
  10. }
  11. }
  12. public function consultarNotificacion() {
  13. $query = Notificacion::find()
  14. ->orderBy(["id" => SORT_ASC]);
  15. $enviando = (clone $query)
  16. ->andWhere(["estatus" => Notificacion::ESTATUS_ENVIANDO])
  17. ->one();
  18. if ($enviando !== null) {
  19. $this->stdout("Notificación en poceso: ". $enviando->id ."\n");
  20. return null;
  21. }
  22. return (clone $query)
  23. ->andWhere(["estatus" => Notificacion::ESTATUS_NUEVO])
  24. ->one();
  25. }
  26. }