Passed
Push — master ( b8147c...403ced )
by Curtis
11:47 queued 05:39
created

PersonTableIndi   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 18
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A query() 0 14 1
1
<?php
2
3
namespace App\Tables\Builders;
4
5
use App\Person;
6
use Illuminate\Database\Eloquent\Builder;
7
use LaravelEnso\Tables\Contracts\Table;
8
use Auth;
9
10
class PersonTableIndi extends \LaravelEnso\People\Tables\Builders\PersonTable
11
{
12
    protected const TemplatePath = __DIR__.'/../Templates/peopleindi.json';
13
14
    public function query(): Builder
15
    {
16
        return Person::selectRaw('
17
            people.id, people.title, people.givn, people.surn,  people.appellative, people.email, people.phone,
18
            people.birthday, CASE WHEN users.id is null THEN 0 ELSE 1 END as "user",
19
            companies.name as company, people.created_at
20
        ')->leftJoin('users', 'people.id', '=', 'users.person_id')
21
            ->leftJoin(
22
                'company_person',
23
                fn ($join) => $join
24
                    ->on('people.id', '=', 'company_person.person_id')
25
                    ->where('company_person.is_main', true)
26
            )->leftJoin('companies', 'company_person.company_id', 'companies.id')
27
            ->where('people.id', Auth::user()->person_id);
0 ignored issues
show
Bug introduced by
Accessing person_id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
28
    }
29
}
30