Passed
Push — master ( 1ffd02...b93f0b )
by Bertrand
06:21
created

User::adminlte_profile_url()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App;
4
5
use App\Src\UseCases\Domain\Ports\OrganizationRepository;
6
use Illuminate\Auth\MustVerifyEmail;
7
use Illuminate\Foundation\Auth\User as Authenticatable;
8
use Illuminate\Notifications\Notifiable;
9
use Illuminate\Support\Facades\Mail;
10
use Spatie\Permission\Traits\HasRoles;
11
12
class User extends Authenticatable implements \Illuminate\Contracts\Auth\MustVerifyEmail
13
{
14
    use Notifiable, HasRoles, MustVerifyEmail;
0 ignored issues
show
introduced by
The trait Spatie\Permission\Traits\HasRoles requires some properties which are not provided by App\User: $name, $map, $permissions, $roles, $guard_name
Loading history...
introduced by
The trait Illuminate\Auth\MustVerifyEmail requires some properties which are not provided by App\User: $email_verified_at, $email
Loading history...
Bug introduced by
The trait Illuminate\Notifications\Notifiable requires the property $email which is not provided by App\User.
Loading history...
15
16
    protected $fillable = [
17
        'firstname', 'lastname', 'email', 'password', 'uuid', 'organization_id', "path_picture", "providers"
18
    ];
19
20
    protected $hidden = [
21
        'password', 'remember_token',
22
    ];
23
24
    protected $casts = [
25
        'email_verified_at' => 'datetime',
26
        'providers' => 'json',
27
        'wiki_stats' => 'json',
28
    ];
29
30
    public function adminlte_image()
31
    {
32
        $urlPicture = $this->path_picture != "" ? asset('storage/'.str_replace('app/public/', '', $this->path_picture)) : null;
0 ignored issues
show
Bug Best Practice introduced by
The property path_picture does not exist on App\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
        if(!isset($urlPicture) || $urlPicture === ""){
34
            $urlPicture = url('').'/'.config('adminlte.logo_img');
35
        }
36
        return $urlPicture;
37
    }
38
39
    public function adminlte_desc()
40
    {
41
        $desc = ucfirst($this->firstname).' '.ucfirst($this->lastname);
0 ignored issues
show
Bug Best Practice introduced by
The property lastname does not exist on App\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
It seems like $this->firstname can also be of type Illuminate\Database\Eloq...uent\Relations\Relation and Illuminate\Database\Eloquent\Relations\Relation; however, parameter $str of ucfirst() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

41
        $desc = ucfirst(/** @scrutinizer ignore-type */ $this->firstname).' '.ucfirst($this->lastname);
Loading history...
Bug Best Practice introduced by
The property firstname does not exist on App\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
42
        if($this->organization_id !== null){
0 ignored issues
show
Bug Best Practice introduced by
The property organization_id does not exist on App\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
43
            $organization = app(OrganizationRepository::class)->get($this->organization_id);
44
            $desc .= ' - organisme : '.$organization->name();
45
        }
46
        return $desc;
47
    }
48
49
    public function adminlte_profile_url()
50
    {
51
        return 'user/edit/profile';
52
    }
53
54
    public function fullname()
55
    {
56
        return ucfirst($this->firstname).' '.ucfirst($this->lastname);
0 ignored issues
show
Bug Best Practice introduced by
The property firstname does not exist on App\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property lastname does not exist on App\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
It seems like $this->firstname can also be of type Illuminate\Database\Eloq...uent\Relations\Relation and Illuminate\Database\Eloquent\Relations\Relation; however, parameter $str of ucfirst() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

56
        return ucfirst(/** @scrutinizer ignore-type */ $this->firstname).' '.ucfirst($this->lastname);
Loading history...
57
    }
58
59
    public function sendEmailVerificationNotification()
60
    {
61
        Mail::to($this->email)->send(new \App\Mail\Auth\VerifyEmail($this));
0 ignored issues
show
Bug Best Practice introduced by
The property email does not exist on App\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
62
    }
63
}
64