BirthdaySms   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 14 2
1
<?php
2
3
namespace App\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use App\Member;
7
use App\Sms_trigger;
8
use Carbon\Carbon;
9
10
class BirthdaySms extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'birthday:sms';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Send birthday wishes to gym members';
25
26
    /**
27
     * Create a new command instance.
28
     *
29
     * @return void
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
    }
35
36
    /**
37
     * Execute the console command.
38
     *
39
     * @return mixed
40
     */
41
    public function handle()
42
    {
43
        $birthdays = Member::whereMonth('DOB','=',Carbon::today()->month)->whereDay('DOB','=',Carbon::today()->day)->where('status','=',\constStatus::Active)->get();
44
        $sender_id = \Utilities::getSetting('sms_sender_id');
45
        $gym_name = \Utilities::getSetting('gym_name');
46
47
        $sms_trigger = Sms_trigger::where('alias','=','member_birthday')->first();
48
        $message = $sms_trigger->message;
49
        $sms_status = $sms_trigger->status;
50
51
        foreach($birthdays as $birthday)
52
        {
53
            $sms_text = sprintf($message,$birthday->name,$gym_name);
54
            \Utilities::Sms($sender_id,$birthday->contact,$sms_text,$sms_status);
55
        }
56
    }
57
}
58