Completed
Push — master ( ac047e...863ff8 )
by Sheela
06:46
created

ExpiringVisits::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 2
1
<?php
2
3
namespace SET\Console\Commands;
4
5
use Carbon\Carbon;
6
use Illuminate\Console\Command;
7
use SET\Visit;
8
9
class ExpiringVisits extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'visits:expiring';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'gets a list of visitation rights that will expire in the next week.';
24
25
    protected $visits;
26
27
    /**
28
     * Create a new command instance.
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct();
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40
    public function handle()
41
    {
42
        $this->visits = Visit::with('user')
43
            ->whereBetween('expiration_date', [
44
                Carbon::today()->subDay()->toDateString(), Carbon::today()->addWeek()->toDateString(),
45
            ])
46
            ->activeUsers()
47
            ->orderBy('expiration_date')
48
            ->get();
49
50
        return $this;
51
    }
52
53
    public function getList()
54
    {
55
        return $this->visits;
56
    }
57
}
58