app/Console/Commands/SendBirthdayReminder.php
/**
     * Execute the console command.
     *
     * @return int
     */
Execute the console command.
@return int
Execute the console command . @return int
public function handle()
    {
           $i = 0;
           $users = User::where('dob', '=', date('m/d/Y'))->get();  
           foreach($users as $user)
           {
                $mobile = MobileVerified::where('user_id', $user->id)->first();
                if($mobile){
                    $mes = 'Today is '.$user->first_name.' Birthday . Please take time and  wish  a happy birthday!';
                    twilioSms($mobile->mobile_number, $mes);
                }
               $email = $user->email;
               $username = $user->first_name.' '.$user->last_name;
               $data   =   ['contents' => 'Today is '.$user->first_name.' Birthday . Please take time and  wish  a happy birthday!'];
               Mail::send('emails.emails', $data, function($message) use ($email, $username) {
                    $message->to($email, $username )->subject
                        ('Birthday Wishes');
                    $message->from((getSettings('admin-receive-email'))? getSettings('admin-receive-email') : env("MAIL_USERNAME", "atulgangapur@gmail.com"), (getSettings('site-title'))? getSettings('site-title') : env("APP_NAME", "Laravel") );
                });
               $i++; 
           }
           $this->info($i.' Birthday messages sent successfully!');
    }
public function handle ( ) { $ i = 0 ; $ users = User :: where ( 'dob' , '=' , date ( 'm/d/Y' ) ) -> get ( ) ; foreach ( $ users as $ user ) { $ mobile = MobileVerified :: where ( 'user_id' , $ user -> id ) -> first ( ) ; if ( $ mobile ) { $ mes = 'Today is ' . $ user -> first_name . ' Birthday . Please take time and  wish  a happy birthday!' ; twilioSms ( $ mobile -> mobile_number , $ mes ) ; } $ email = $ user -> email ; $ username = $ user -> first_name . ' ' . $ user -> last_name ; $ data = [ 'contents' => 'Today is ' . $ user -> first_name . ' Birthday . Please take time and  wish  a happy birthday!' ] ; Mail :: send ( 'emails.emails' , $ data , function ( $ message ) use ( $ email , $ username ) { $ message -> to ( $ email , $ username ) -> subject ( 'Birthday Wishes' ) ; $ message -> from ( ( getSettings ( 'admin-receive-email' ) ) ? getSettings ( 'admin-receive-email' ) : env ( " MAIL_USERNAME " , " atulgangapur@gmail.com " ) , ( getSettings ( 'site-title' ) ) ? getSettings ( 'site-title' ) : env ( " APP_NAME " , " Laravel " ) ) ; } ) ; $ i ++ ; } $ this -> info ( $ i . ' Birthday messages sent successfully!' ) ; }
Execute the console command.
Execute the console command .