| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace app\components;
- use app\models\Notificacion;
- use yii\console\Controller;
- use yii\db\Expression;
- class NotificacionController extends Controller {
- public $debug = true;
- public function stdout($texto) {
- if ($this->debug) {
- parent::stdout($texto);
- }
- }
- public function consultarNotificacion() {
- $query = Notificacion::find()
- ->orderBy(["envio" => 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(["<", "envio", new Expression('now()')])
- ->andWhere(["estatus" => Notificacion::ESTATUS_NUEVO])
- ->one();
- }
- }
|