-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.php
More file actions
73 lines (60 loc) · 1.32 KB
/
Copy pathUser.php
File metadata and controls
73 lines (60 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace App;
use App\Photos;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password','role_id','photo_id'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function role()
{
return $this->belongsTo('App\Role');
}
public function getIsActiveStringAttribute()
{
if($this->is_active == 1)
return "Active";
else
return "Not Active";
}
public function photo()
{
return $this->belongsTo('App\Photos');
}
public function isAdmin()
{
if( $this->role_id == Role ::where('name','administrator')->first()->id && $this->isActive() )
{
return true;
}
else{
return false;
}
}
public function isActive()
{
if($this->is_active == 1)
return true;
else
return false;
}
public function posts() {
return $this->hasMany('App\Post');
}
}