FollowupSms   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 handle() 0 14 2
A __construct() 0 3 1
1
<?php
2
3
namespace App\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use App\Followup;
7
use App\Sms_trigger;
8
use Carbon\Carbon;
9
10
class FollowupSms extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'followup:sms';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Triggers sms for followups scheduled for the day';
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
        $followups = Followup::where('due_date','=',Carbon::today())->get();
44
45
        $sms_trigger = Sms_trigger::where('alias','=','followup')->first();
46
        $message = $sms_trigger->message;        
47
        $sms_status = $sms_trigger->status;
48
        $sender_id = \Utilities::getSetting('sms_sender_id');
49
        $gym_name = \Utilities::getSetting('gym_name');
50
51
        foreach ($followups as $followup) 
52
        {
53
            $sms_text = sprintf($message,$followup->enquiry->name,$gym_name);
54
            \Utilities::Sms($sender_id,$followup->enquiry->contact,$sms_text,$sms_status);
55
        }
56
    }
57
}
58