|
@@ -31,31 +31,39 @@ class SendSms extends Command
|
|
|
$expire_date = date("Y-m-d", strtotime("+1 month"));
|
|
$expire_date = date("Y-m-d", strtotime("+1 month"));
|
|
|
$expire_date_it = date("d/m/Y", strtotime("+1 month"));
|
|
$expire_date_it = date("d/m/Y", strtotime("+1 month"));
|
|
|
$certificates = \App\Models\MemberCertificate::where('expire_date', $expire_date)->get();
|
|
$certificates = \App\Models\MemberCertificate::where('expire_date', $expire_date)->get();
|
|
|
- foreach ($certificates as $certificate) {
|
|
|
|
|
- $phone = $certificate->member->phone;
|
|
|
|
|
- $message = 'Ciao ' . $certificate->member->first_name . ', ci risulta che il tuo certificato medico scade il ' . $expire_date_it . '. Per continuare ad allenarti senza problemi, ricordati di rinnovarlo in tempo. Ti aspettiamo in campo! Centro Sportivo La Madonnella';
|
|
|
|
|
- $params = array(
|
|
|
|
|
- 'to' => '+39' . $phone,
|
|
|
|
|
- 'from' => env('SMS_FROM', 'Test'),
|
|
|
|
|
- 'message' => $message,
|
|
|
|
|
- 'format' => 'json',
|
|
|
|
|
- );
|
|
|
|
|
- sms_send($params);
|
|
|
|
|
|
|
+ foreach ($certificates as $certificate) {
|
|
|
|
|
+ $new = \App\Models\MemberCertificate::where('expire_date', '>', $expire_date)->count();
|
|
|
|
|
+ if ($new == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ $phone = $certificate->member->phone;
|
|
|
|
|
+ $message = 'Ciao ' . $certificate->member->first_name . ', ci risulta che il tuo certificato medico scade il ' . $expire_date_it . '. Per continuare ad allenarti senza problemi, ricordati di rinnovarlo in tempo. Ti aspettiamo in campo! Centro Sportivo La Madonnella';
|
|
|
|
|
+ $params = array(
|
|
|
|
|
+ 'to' => '+39' . $phone,
|
|
|
|
|
+ 'from' => env('SMS_FROM', 'Test'),
|
|
|
|
|
+ 'message' => $message,
|
|
|
|
|
+ 'format' => 'json',
|
|
|
|
|
+ );
|
|
|
|
|
+ sms_send($params);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$expire_date = date("Y-m-d", strtotime("+15 days"));
|
|
$expire_date = date("Y-m-d", strtotime("+15 days"));
|
|
|
$expire_date_it = date("d/m/Y", strtotime("+15 days"));
|
|
$expire_date_it = date("d/m/Y", strtotime("+15 days"));
|
|
|
$certificates = \App\Models\MemberCertificate::where('expire_date', $expire_date)->get();
|
|
$certificates = \App\Models\MemberCertificate::where('expire_date', $expire_date)->get();
|
|
|
foreach ($certificates as $certificate) {
|
|
foreach ($certificates as $certificate) {
|
|
|
- $phone = $certificate->member->phone;
|
|
|
|
|
- $message = 'Ciao ' . $certificate->member->first_name . ', ci risulta che il tuo certificato medico scade il ' . $expire_date_it . '. Per continuare ad allenarti senza problemi, ricordati di rinnovarlo in tempo. Ti aspettiamo in campo! Centro Sportivo La Madonnella';
|
|
|
|
|
- $params = array(
|
|
|
|
|
- 'to' => '+39' . $phone,
|
|
|
|
|
- 'from' => env('SMS_FROM', 'Test'),
|
|
|
|
|
- 'message' => $message,
|
|
|
|
|
- 'format' => 'json',
|
|
|
|
|
- );
|
|
|
|
|
- sms_send($params);
|
|
|
|
|
|
|
+ $new = \App\Models\MemberCertificate::where('expire_date', '>', $expire_date)->count();
|
|
|
|
|
+ if ($new == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ $phone = $certificate->member->phone;
|
|
|
|
|
+ $message = 'Ciao ' . $certificate->member->first_name . ', ci risulta che il tuo certificato medico scade il ' . $expire_date_it . '. Per continuare ad allenarti senza problemi, ricordati di rinnovarlo in tempo. Ti aspettiamo in campo! Centro Sportivo La Madonnella';
|
|
|
|
|
+ $params = array(
|
|
|
|
|
+ 'to' => '+39' . $phone,
|
|
|
|
|
+ 'from' => env('SMS_FROM', 'Test'),
|
|
|
|
|
+ 'message' => $message,
|
|
|
|
|
+ 'format' => 'json',
|
|
|
|
|
+ );
|
|
|
|
|
+ sms_send($params);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return Command::SUCCESS;
|
|
return Command::SUCCESS;
|