Completed
Push — master ( cbdb30...d40a37 )
by Emmanuel
01:09
created

AutoCloseCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace RexlManu\LaravelTickets\Commands;
5
6
use Illuminate\Console\Command;
7
use RexlManu\LaravelTickets\Events\TicketCloseEvent;
8
use RexlManu\LaravelTickets\Models\Ticket;
9
10
class AutoCloseCommand extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'tickets:autoclose';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Close any ticket that has become inactive.';
25
26
    /**
27
     * Execute the console command.
28
     *
29
     * @return int
30
     */
31
    public function handle()
32
    {
33
        $tickets = Ticket::query()->where(
34
            'updated_at',
35
            '<',
36
            now()->subDays(config('laravel-tickets.autoclose-days'))
37
        );
38
39
        $tickets->update([ 'state' => 'CLOSED' ]);
40
        $tickets->get()->each(fn(Ticket $ticket) => event(new TicketCloseEvent($ticket)));
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_VARIABLE, expecting ',' or ')'
Loading history...
41
    }
42
}
43