TenantLogout::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 0
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
3
namespace App\Listeners;
4
5
use App\Models\Tree;
6
use DB;
7
use Illuminate\Auth\Events\Logout;
8
use Illuminate\Contracts\Queue\ShouldQueue;
9
use Illuminate\Queue\InteractsWithQueue;
10
use Spatie\Multitenancy\Models\Concerns\UsesLandlordConnection;
11
use Spatie\Multitenancy\Models\Tenant;
12
13
class TenantLogout
14
{
15
    use UsesLandlordConnection;
16
17
    /**
18
     * Create the event listener.
19
     *
20
     * @return void
21
     */
22
    public function __construct()
23
    {
24
        //
25
    }
26
27
    /**
28
     * Handle the event.
29
     *
30
     * @param  Logout  $event
31
     * @return void
32
     */
33
    public function handle(Logout $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
    public function handle(/** @scrutinizer ignore-unused */ Logout $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        $user = auth()->user();
36
        $company = DB::connection($this->getConnectionName())->table('user_company')->where('user_id', $user->id)->select('company_id')->first();
37
        $tree = Tree::where('company_id', $company->company_id)->first();
38
        $tenant = Tenant::where('tree_id', $tree->id)->first();
39
        session()->flush();
40
        $tenant->forgetCurrent();
41
    }
42
}
43