Completed
Push — master ( c86b4a...6e0f3c )
by Shawn
05:29
created

ResolveLdap::activateUsers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace SET\Listeners;
4
5
use Carbon\Carbon;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Support\Facades\Artisan;
8
use SET\User;
9
10
class ResolveLdap implements ShouldQueue
11
{
12
    /**
13
     * Build the event handler.
14
     */
15
    public function __construct()
16
    {
17
        //
18
    }
19
20
    /**
21
     * Call to add missing users.
22
     */
23
    public function handle()
24
    {
25
        if (config('auth.providers.users.driver') == 'adldap') {
26
            Artisan::call('adldap:import');
27
            $this->activateUsers();
28
        }
29
    }
30
31
    private function activateUsers()
32
    {
33
        User::whereBetween('created_at', [Carbon::now()->subMinutes(3), Carbon::now()])
34
        ->update(['status' => 'active']);
35
    }
36
}
37