| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace app\components;
- use app\models\Notificacion;
- use yii\console\Controller;
- class NotificacionController extends Controller {
- public $debug = true;
- public function stdout($texto) {
- if ($this->debug) {
- parent::stdout($texto);
- }
- }
- public function consultarNotificacion() {
- $query = Notificacion::find()
- ->orderBy(["id" => SORT_ASC]);
- $enviando = (clone $query)
- ->andWhere(["estatus" => Notificacion::ESTATUS_ENVIANDO])
- ->one();
-
- if ($enviando !== null) {
- $this->stdout("Notificación en poceso: ". $enviando->id ."\n");
- return null;
- }
- return (clone $query)
- ->andWhere(["estatus" => Notificacion::ESTATUS_NUEVO])
- ->one();
- }
- }
|