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; |
|
|
|
|
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; |
|
|
|
|
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); |
|
|
|
|
42
|
|
|
if($this->organization_id !== null){ |
|
|
|
|
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); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function sendEmailVerificationNotification() |
60
|
|
|
{ |
61
|
|
|
Mail::to($this->email)->send(new \App\Mail\Auth\VerifyEmail($this)); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|