コード例 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $jobs = Job::whereNull('texted_at')->where('job_status_id', '=', JobStatus::$OPEN)->where('start_date', '>=', date("Y-m-d"))->orderBy("start_date")->get();
     $catJobs = array();
     $users = array();
     $userJobs = array();
     $userCategories = array();
     $user_ids = array();
     $jobs->load("jobCategory", "user");
     // echo '<pre>';
     //print_r($jobs);
     //echo '</pre>';
     foreach ($jobs as $job) {
         if (trim($job->latitude) != "" && trim($job->longitude) != "") {
             $userAddresses = Address::select("addresses.*", "student_profile.preferred_job_radius", Address::distanceSelectStatement($job->latitude, $job->longitude, 'distance', 'addresses'))->join("student_profile", "addresses.user_id", "=", "student_profile.user_id")->get();
             foreach ($userAddresses as $address) {
                 if ($address->distance > 0 && $address->distance <= $address->preferred_job_radius) {
                     //echo "here".$address->distance;
                     if (!isset($userCategories[$address->user_id])) {
                         $userCategories[$address->user_id] = StudentJobPreference::where('user_id', '=', $address->user_id)->lists('job_category_id');
                     }
                     if (in_array($job->job_category_id, $userCategories[$address->user_id]) == 1) {
                         if (!isset($userJobs[$address->user_id])) {
                             $user_ids[] = $address->user_id;
                             $userJobs[$address->user_id] = array();
                             $users[$address->user_id] = $address->user;
                         }
                         $userJobs[$address->user_id][] = $job;
                     }
                 }
             }
         }
         //$job->notified_at=date('Y-m-d h:i:s');
         $job->texted_at = date('Y-m-d h:i:s');
         $job->save();
     }
     $c = 0;
     if (count($user_ids) > 0) {
         $notifications = UserNotification::whereIn('user_id', $user_ids)->where("notification_types_id", '=', NotificationType::$SMS)->get();
         foreach ($notifications as $notification) {
             $user = $users[$notification->user_id];
             //$this->info($user->id);
             $c++;
             $this->info($notification->notification_value);
             $message = View::make('sms.commands.job_notifications');
             if (trim($notification->notification_value) != "" && !is_null($notification->notification_value)) {
                 try {
                     Twilio::message($notification->notification_value, substr($message, 0, 160));
                 } catch (Exception $e) {
                     \Log::info('Error: ' . $e->getMessage());
                     $this->info('Error: ' . $e->getMessage());
                 }
             }
         }
     }
     \Log::info('Cron Notification Text: ' . $c);
     $this->info($c . 'text sent');
 }
コード例 #2
0
 public function sendVerification($mobile, $passcode)
 {
     try {
         Twilio::message("+91{$mobile}", "Enter {$passcode} on the sign up page to verify your account. This is one time message from Couture.");
         return true;
     } catch (Exception $exc) {
         //echo $exc->getTraceAsString();
         return false;
     }
 }
コード例 #3
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->line('Sending SMS via Twilio to: ' . $this->argument('phone'));
     // Grab the text option if specified
     $text = $this->option('text');
     // If we havent specified a message, setup a default one
     if (is_null($text)) {
         $text = "This is a test message sent from the artisan console";
     }
     $this->line($text);
     \Twilio::message($this->argument('phone'), $text);
 }
コード例 #4
0
ファイル: JobsController.php プロジェクト: aeastmead/blinxly
 private function NotifyFavorite($user, $job)
 {
     foreach ($user->userNotifications as $notification) {
         switch ($notification->notification_types_id) {
             case NotificationType::$SMS:
                 try {
                     $message = View::make("sms.job_applicant.private_awarded", compact('job'));
                     Twilio::message($notification->notification_value, substr($message, 0, 160));
                 } catch (Exception $e) {
                     //$notify->notes=print_r($e,true);
                     //\Log::info(print_r($e,true));
                 }
                 break;
             case NotificationType::$ALTERNATIVEEMAIL:
                 if (trim($notification->notification_value) != "") {
                     try {
                         Mail::send('emails.job_applicants.private_awardee', array('awardee' => $user, 'job' => $job), function ($message) use($notification, $user) {
                             $message->from('*****@*****.**', 'QuadJobs');
                             $message->to($notification->notification_value, $user->first_name . ' ' . $user->last_name);
                             $message->subject('Job Revoked');
                         });
                     } catch (Exception $e) {
                         //$notify->notes=print_r($e,true);
                         //\Log::info(print_r($e,true));
                     }
                 }
                 break;
             case NotificationType::$EDUEMAIL:
                 try {
                     Mail::send('emails.job_applicants.private_awardee', array('awardee' => $user, 'job' => $job), function ($message) use($student) {
                         $message->from('*****@*****.**', 'QuadJobs');
                         $message->to($student->email, $student->first_name . ' ' . $student->last_name);
                         $message->subject('Job Revoked');
                     });
                 } catch (Exception $e) {
                     //$notify->notes=print_r($e,true);
                     //\Log::info(print_r($e,true));
                 }
                 break;
         }
     }
 }
コード例 #5
0
 public function registerMultipleUsers()
 {
     $input = Input::all();
     //dd(Input::all());
     //$input = json_decode(Input::get('data'));
     //$input = json_decode($json);
     \Log::error($input);
     \Log::error($input['event']);
     $event_num = $input['event'];
     $names = $input['names'];
     //$event_num = $input->event;
     //$names = $input->names;
     //dd($event_num);
     for ($i = 0; $i < count($names); $i++) {
         \Log::error($names[$i]);
         $user = User::where('name', '=', $names[$i])->first();
         \Log::error($user);
         if (isset($user)) {
             $user->occasions()->attach($event_num);
             $user->save();
             $app_id = 'jVmr9Q4ItzKs2abze4T2mRvECJ8AxMwCKT5G8anC';
             $rest_key = 'hNv7GwawFKdvpyb6B6u8sLqlSQMW3YWWRQeKVll7';
             $master_key = 'wzwEOPsb5w45qWQQVJSCqTtL6yvD82Y90SiVDh4y';
             ParseClient::initialize($app_id, $rest_key, $master_key);
             $data = array("alert" => "You have been invited to an event! Press here to learn more.");
             $query = ParseInstallation::query();
             $query->equalTo("device_id", $user->id);
             ParsePush::send(array("where" => $query, "data" => $data));
             Twilio::message($user->phone, 'You have been invited to an event! Open up Calendr to learn more.');
             $data = array('temp');
             /*
             		Mail::send('emails.invite', $data, function($message) use ($user)
             		{
             			\Log::info($user->email);
             		    $message->to($user->email, 'Jane Doe')->subject('You have been invited to an event!');
             		});
             */
         }
     }
 }
コード例 #6
0
 function sendmessage($destination)
 {
     global $club, $messageData, $messageSubject, $event, $sms, $user, $recipientMobile, $recipientEmail;
     foreach ($destination as $recipient) {
         //send email notification of acceptance queue
         $data = array('club' => $club, 'messageOriginal' => $messageData, 'subject' => $messageSubject, 'team' => $event);
         Mail::later(3, 'emails.announcement.default', $data, function ($message) use($recipient, $club, $messageSubject) {
             $message->to($recipient['email'], $recipient['name'])->subject("{$messageSubject} | " . $club->name);
         });
         $recipientEmail[] = array('name' => $recipient['name'], 'email' => $recipient['email']);
         if (Input::get('sms')) {
             $recipientMobile[] = array('name' => $recipient['name'], 'mobile' => $recipient['mobile']);
             //queue sms
             Queue::push(function ($job) use($recipient, $sms) {
                 Twilio::message($recipient['mobile'], $sms);
                 $job->delete();
             });
         }
     }
 }
コード例 #7
0
ファイル: routes.php プロジェクト: wyrover/aeroeco
     });
     return 'Email Sent!';
 });
 Route::get('xlimport/{dir}/{file}', ['as' => 'xlimport', 'uses' => 'ExcelController@fromExcel']);
 Route::get('event', function () {
     logit('created a test event');
 });
 Route::get('tester', function () {
     return view('pages.tester');
 });
 Route::get('notifier', function () {
     notify(Auth::user()->id, '2', 'Angelina Jole just friended you.');
     return 'Notification Saved!';
 });
 Route::get('sms/{phone}', function ($phone) {
     Twilio::message($phone, 'Hi, I am Echo from the AeroEco software. I can now send but not receive text messages. Pretty cool, huh?');
     return 'Message sent';
 });
 Route::get('messenger', function () {
     tweet('2', 'Dude, why are you sending yourself a message? Are you some kind of freak? Oh, you are just testing.');
     return 'Message Saved!';
 });
 Route::get('systemic', function () {
     $user = Auth::user();
     Activity::log(['contentId' => null, 'contentType' => 'User', 'action' => 'LogIn', 'description' => 'Logged In', 'details' => 'Username: '******'updated' => (bool) $user->id]);
     return 'Activity logged';
 });
 Route::get('welcome_page', function () {
     flash()->overlay('Hello, World!', 'This is the message');
     return view('pages.welcome');
 });
コード例 #8
0
 public function message($number, $message)
 {
     return \Twilio::message($number, $message);
 }
コード例 #9
0
    public function storeSchedule()
    {
        $input['json'] = '{
						    "user": "******",
						    "event": "1",
						    "time_slots": [
						        {
						            "start": 1411239474,
						            "end": 1411539474,
						            "weighting": "5"
						        },
						        {
						            "start": 1411269474,
						            "end": 1411549474,
						            "weighting": "5"
						        }
						    ]
						}';
        $decoded = json_decode($input['json']);
        $user_id = $decoded->user;
        $occasion_id = $decoded->event;
        // Get the occasion tied to the user
        $occasion = User::find($user_id)->occasions->find($occasion_id);
        if ($occasion == null) {
            return null;
        }
        $time_slots = $decoded->time_slots;
        $insert = array();
        for ($i = 0; $i < count($time_slots); $i++) {
            $start = $time_slots[$i]->start;
            $ts_start = Carbon::createFromTimeStamp($start);
            $end = $time_slots[$i]->end;
            $ts_end = Carbon::createFromTimeStamp($end);
            $insert[] = array('start' => $ts_start->toDateTimeString(), 'end' => $ts_end->toDateTimeString(), 'weighting' => $time_slots[$i]->weighting, 'user_id' => $user_id, 'occasion_id' => $occasion_id);
        }
        //dd($insert);
        Timeslot::insert($insert);
        $occasion->pivot->complete = 1;
        $occasion->pivot->save();
        $num_incomplete_occasions = Occasion::find($occasion_id)->users()->wherePivot('complete', 0)->count();
        if ($num_incomplete_occasions != 0) {
            return $occasion;
        }
        // The events are done - push
        $occasion = Occasion::find($occasion_id);
        $host_start = new Carbon($occasion->start);
        $host_end = new Carbon($occasion->end);
        $diff = $host_start->diffInMinutes($host_end);
        $num_users = $occasion->users->count();
        $score = array();
        $score = array_fill(0, 10000, 0);
        //$score[0] = 'test';
        //$score = 0;
        $k = 0;
        $previous = new Carbon($occasion->start);
        // implement eager loading
        for ($i = 0; $i < $diff; $i += 15) {
            for ($j = 0; $j < $num_users; $j++) {
                $start = new Carbon($occasion->start);
                $start->addMinutes($i);
                $timeslot = Timeslot::where('user_id', '=', $j)->where('start', '<=', $previous->toDateTimeString())->where('end', '>=', $start->toDateTimeString())->first();
                if ($timeslot != null) {
                    //dd($timeslot);
                    //$score = array_add($score, $i, $timeslot->weighting);
                    $score[$i] += $timeslot->weighting;
                    //$score[$i] += $timeslot->weighting;
                    //$score[] = array($timeslot->weighting);
                    //$k++;
                    //var_dump($score);
                }
            }
            $previous = $start;
        }
        $score = array_filter($score);
        //dd($score);
        rsort($score);
        $top3 = array_reverse(array_slice($score, 0, 3));
        $users = Occasion::find($occasion_id)->users()->get();
        $data = array('temp');
        $users = $users->each(function ($user) use($data) {
            \Mail::send('emails.invite', $data, function ($message) use($user) {
                $message->to($user->email, $user->name)->subject('Your event has been scheduled!');
            });
            \Twilio::message($user->phone, 'An event has finished scheduling! Open up Calendr to learn more.');
        });
        $app_id = 'jVmr9Q4ItzKs2abze4T2mRvECJ8AxMwCKT5G8anC';
        $rest_key = 'hNv7GwawFKdvpyb6B6u8sLqlSQMW3YWWRQeKVll7';
        $master_key = 'wzwEOPsb5w45qWQQVJSCqTtL6yvD82Y90SiVDh4y';
        ParseClient::initialize($app_id, $rest_key, $master_key);
        $data = array("alert" => "An event has finished scheduling! Press here to learn more.");
        ParsePush::send(array("channels" => ["PHPFans"], "data" => $data));
        $query = ParseInstallation::query();
        $query->equalTo("design", "rad");
        ParsePush::send(array("where" => $query, "data" => $data));
        //	dd($score);
    }
コード例 #10
0
ファイル: test.php プロジェクト: abhiyadav001/Monkey
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
// public function sendVerification($mobile, $passcode){
$var = Twilio::message("+919711987169", "Enter  on the sign up page to verify your account. This is one time message from Couture.");
print_r($var);
// }