src/CrudGeneratorCommands.php
public function sendalert() {
        $alertaClass = $this->console->ask("Notification Class?");
        if (class_exists($alertaClass)) {
            $email = $this->console->anticipate("User email?", ['andres.espinosa@grimorum.com']);
            if ($toUser = \App\User::where("email", "=", $email)->first()) {
                $message = $this->console->ask("Message?");
                /* $options = array(
                  'cluster' => 'us2',
                  'encrypted' => true
                  );
                  $pusher = new Pusher(
                  'adf503a8756876656ec6', 'b21a0ee639fbb893e41d', '481076', $options
                  );
                 */
                $data = [];
                $data['message'] = $message;
                /* $result = $pusher->trigger('my-channel', 'my-event', $data, null, true);
                  $this->console->line(print_r($result, true)); */
                $tiempo = $this->console->ask("Send in? (Just a number,next you will select seconds, minutes, etc.)");
                if (!is_int((int) $tiempo)) {
                    $tiempo = $this->console->ask("Send in? HAS TO BE AN INTEGER NUMBER");
                }
                if (is_int((int) $tiempo)) {
                    $unidad = $this->console->choice('...', ['seconds', 'minutes', 'hours', 'days'], 0);
                    switch ($unidad) {
                        case 'seconds':
                            $when = now()->addSeconds($tiempo);
                            break;
                        case 'minutes':
                            $when = now()->addMinutes($tiempo);
                            break;
                        case 'hours':
                            $when = now()->addHours($tiempo);
                            break;
                        case 'days':
                            $when = now()->addDays($tiempo);
                            break;
                        default:
                            $when = now()->addMinutes($tiempo);
                            break;
                    }
                    $toUser->notify((new $alertaClass($data))
                                    ->delay($when)
                    );
                    $this->console->info("Listo!");
                } else {
                    $this->console->error("Paila!");
                }
            } else {
                $this->console->error("User not found");
            }
        } else {
            $this->console->error("Class not found");
        }
    }
public function sendalert() {
        $alertaClass = $this->console->ask("Notification Class?");
        if (class_exists($alertaClass)) {
            $email = $this->console->anticipate("User email?", ['andres.espinosa@grimorum.com']);
            if ($toUser = \App\User::where("email", "=", $email)->first()) {
                $message = $this->console->ask("Message?");
                /* $options = array(
                  'cluster' => 'us2',
                  'encrypted' => true
                  );
                  $pusher = new Pusher(
                  'adf503a8756876656ec6', 'b21a0ee639fbb893e41d', '481076', $options
                  );
                 */
                $data = [];
                $data['message'] = $message;
                /* $result = $pusher->trigger('my-channel', 'my-event', $data, null, true);
                  $this->console->line(print_r($result, true)); */
                $tiempo = $this->console->ask("Send in? (Just a number,next you will select seconds, minutes, etc.)");
                if (!is_int((int) $tiempo)) {
                    $tiempo = $this->console->ask("Send in? HAS TO BE AN INTEGER NUMBER");
                }
                if (is_int((int) $tiempo)) {
                    $unidad = $this->console->choice('...', ['seconds', 'minutes', 'hours', 'days'], 0);
                    switch ($unidad) {
                        case 'seconds':
                            $when = now()->addSeconds($tiempo);
                            break;
                        case 'minutes':
                            $when = now()->addMinutes($tiempo);
                            break;
                        case 'hours':
                            $when = now()->addHours($tiempo);
                            break;
                        case 'days':
                            $when = now()->addDays($tiempo);
                            break;
                        default:
                            $when = now()->addMinutes($tiempo);
                            break;
                    }
                    $toUser->notify((new $alertaClass($data))
                                    ->delay($when)
                    );
                    $this->console->info("Listo!");
                } else {
                    $this->console->error("Paila!");
                }
            } else {
                $this->console->error("User not found");
            }
        } else {
            $this->console->error("Class not found");
        }
    }
public function sendalert ( ) { $ alertaClass = $ this -> console -> ask ( "Notification Class?" ) ; if ( class_exists ( $ alertaClass ) ) { $ email = $ this -> console -> anticipate ( "User email?" , [ 'andres.espinosa@grimorum.com' ] ) ; if ( $ toUser = \ App \ User :: where ( "email" , "=" , $ email ) -> first ( ) ) { $ message = $ this -> console -> ask ( "Message?" ) ; /* $options = array(
                  'cluster' => 'us2',
                  'encrypted' => true
                  );
                  $pusher = new Pusher(
                  'adf503a8756876656ec6', 'b21a0ee639fbb893e41d', '481076', $options
                  );
                 */ $ data = [ ] ; $ data [ 'message' ] = $ message ; /* $result = $pusher->trigger('my-channel', 'my-event', $data, null, true);
                  $this->console->line(print_r($result, true)); */ $ tiempo = $ this -> console -> ask ( "Send in? (Just a number,next you will select seconds, minutes, etc.)" ) ; if ( ! is_int ( ( int ) $ tiempo ) ) { $ tiempo = $ this -> console -> ask ( "Send in? HAS TO BE AN INTEGER NUMBER" ) ; } if ( is_int ( ( int ) $ tiempo ) ) { $ unidad = $ this -> console -> choice ( '...' , [ 'seconds' , 'minutes' , 'hours' , 'days' ] , 0 ) ; switch ( $ unidad ) { case 'seconds' : $ when = now ( ) -> addSeconds ( $ tiempo ) ; break ; case 'minutes' : $ when = now ( ) -> addMinutes ( $ tiempo ) ; break ; case 'hours' : $ when = now ( ) -> addHours ( $ tiempo ) ; break ; case 'days' : $ when = now ( ) -> addDays ( $ tiempo ) ; break ; default : $ when = now ( ) -> addMinutes ( $ tiempo ) ; break ; } $ toUser -> notify ( ( new $ alertaClass ( $ data ) ) -> delay ( $ when ) ) ; $ this -> console -> info ( "Listo!" ) ; } else { $ this -> console -> error ( "Paila!" ) ; } } else { $ this -> console -> error ( "User not found" ) ; } } else { $ this -> console -> error ( "Class not found" ) ; } }
Broadcast an alert to a user
Broadcast an alert to a user