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

UserTableIndi::templatePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Tables\Builders\enso\core;
4
5
use App\Models\User;
6
use Illuminate\Database\Eloquent\Builder;
7
use LaravelEnso\Tables\Contracts\Table;
8
use Auth;
9
class UserTableIndi implements Table
10
{
11
    protected const TemplatePath = __DIR__.'/../../../Templates/enso/core/user.json';
12
13
    protected $query;
14
15
    public function query(): Builder
16
    {
17
        return User::with('person:id,appellative,name', 'avatar:id,user_id')->selectRaw('
0 ignored issues
show
Bug Best Practice introduced by
The expression return App\Models\User::....id', Auth::user()->id) could return the type Illuminate\Database\Query\Builder which is incompatible with the type-hinted return Illuminate\Database\Eloquent\Builder. Consider adding an additional type-check to rule them out.
Loading history...
18
            users.id, user_groups.name as userGroup, people.name, people.appellative,
19
            people.phone, users.email, roles.name as role, users.is_active,
20
            users.created_at, users.person_id
21
        ')->join('people', 'users.person_id', '=', 'people.id')
22
            ->join('user_groups', 'users.group_id', '=', 'user_groups.id')
23
            ->join('roles', 'users.role_id', '=', 'roles.id')
24
            ->where('users.id', Auth::user()->id);
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
25
    }
26
27
    public function templatePath(): string
28
    {
29
        return static::TemplatePath;
30
    }
31
}
32