Completed
Pull Request — master (#21)
by Shawn
08:00 queued 05:52
created

ExpiringVisits   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 12 1
A getList() 0 4 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
    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