Completed
Push — Framework-Dependencies-Upgrade ( 998813...01c962 )
by Sheela
07:38
created

ExpiringVisits::getList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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 2
    public function __construct()
31
    {
32 2
        parent::__construct();
33 2
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40 2
    public function handle()
41
    {
42 2
        $this->visits = Visit::with('user')
43 2
            ->whereBetween('expiration_date', [
44 2
                Carbon::today()->subDay()->toDateString(), Carbon::today()->addWeek()->toDateString(),
45
            ])
46 2
            ->activeUsers()
47 2
            ->orderBy('expiration_date')
48 2
            ->get();
49
50 2
        return $this;
51
    }
52
53 2
    public function getList()
54
    {
55 2
        return $this->visits;
56
    }
57
}
58