1 | <?php namespace jlourenco\base\Models; |
||
6 | class BaseUser extends EloquentUser |
||
7 | { |
||
8 | |||
9 | /** |
||
10 | * The database table used by the model. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $table = 'User'; |
||
15 | |||
16 | /** |
||
17 | * The attributes excluded from the model's JSON form. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $hidden = array('password', 'remember_token'); |
||
22 | |||
23 | /** |
||
24 | * The attributes used to test the login against. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $loginNames = ['username', 'email']; |
||
29 | |||
30 | /** |
||
31 | * {@inheritDoc} |
||
32 | */ |
||
33 | protected $fillable = [ |
||
34 | 'username', |
||
35 | 'email', |
||
36 | 'password', |
||
37 | 'last_name', |
||
38 | 'first_name', |
||
39 | 'permissions', |
||
40 | 'birthday', |
||
41 | 'status', |
||
42 | 'ip', |
||
43 | 'staff', |
||
44 | ]; |
||
45 | |||
46 | /** |
||
47 | * The attributes that will appear on the register form. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $registerFields = [ |
||
52 | 'first_name' => [ |
||
53 | 'type' => 'text', |
||
54 | 'validator' => 'required|min:3|max:25', |
||
55 | 'label' => 'First name', |
||
56 | 'placeholder' => 'You first name', |
||
57 | 'classes' => 'form-control input-lg JQMaxLength', |
||
58 | 'maxlength' => 25, |
||
59 | 'save' => true |
||
60 | ], |
||
61 | 'last_name' => [ |
||
62 | 'type' => 'text', |
||
63 | 'validator' => 'required|min:3|max:25', |
||
64 | 'label' => 'Last name', |
||
65 | 'placeholder' => 'You last name', |
||
66 | 'classes' => 'form-control input-lg JQMaxLength', |
||
67 | 'maxlength' => 25, |
||
68 | 'save' => true |
||
69 | ], |
||
70 | 'username' => [ |
||
71 | 'type' => 'text', |
||
72 | 'validator' => 'required|min:3|unique:User|max:25', |
||
73 | 'label' => 'Username', |
||
74 | 'placeholder' => 'You username', |
||
75 | 'classes' => 'form-control input-lg JQMaxLength', |
||
76 | 'maxlength' => 25, |
||
77 | 'save' => true |
||
78 | ], |
||
79 | 'email' => [ |
||
80 | 'type' => 'text', |
||
81 | 'validator' => 'required|email|unique:User,email,3,status|max:255', |
||
82 | 'label' => 'Email', |
||
83 | 'placeholder' => 'Your email', |
||
84 | 'classes' => 'form-control input-lg JQMaxLength', |
||
85 | 'maxlength' => 255, |
||
86 | 'save' => true |
||
87 | ], |
||
88 | 'email_confirm' => [ |
||
89 | 'type' => 'text', |
||
90 | 'validator' => 'required|email|same:email', |
||
91 | 'label' => 'Confirm email', |
||
92 | 'placeholder' => 'Confirm your email', |
||
93 | 'classes' => 'form-control input-lg JQMaxLength', |
||
94 | 'maxlength' => 255, |
||
95 | 'save' => false |
||
96 | ], |
||
97 | 'password' => [ |
||
98 | 'type' => 'password', |
||
99 | 'validator' => 'required|between:3,32', |
||
100 | 'label' => 'Password', |
||
101 | 'placeholder' => 'You password', |
||
102 | 'classes' => 'form-control input-lg JQMaxLength', |
||
103 | 'maxlength' => 30, |
||
104 | 'save' => true |
||
105 | ], |
||
106 | 'password_confirm' => [ |
||
107 | 'type' => 'password', |
||
108 | 'validator' => 'required|same:password', |
||
109 | 'label' => 'Confirm password', |
||
110 | 'placeholder' => 'Confirm your password', |
||
111 | 'classes' => 'form-control input-lg JQMaxLength', |
||
112 | 'maxlength' => 30, |
||
113 | 'save' => false |
||
114 | ], |
||
115 | 'birthday' => [ |
||
116 | 'type' => 'text', |
||
117 | 'validator' => 'date_format:d/m/Y|before:now', |
||
118 | 'label' => 'Birthday', |
||
119 | 'placeholder' => 'Your birthday', |
||
120 | 'classes' => 'form-control input-lg JQCalendar', |
||
121 | 'maxlength' => 25, |
||
122 | 'save' => true |
||
123 | ], |
||
124 | ]; |
||
125 | |||
126 | /** |
||
127 | * To allow soft deletes |
||
128 | */ |
||
129 | use SoftDeletes; |
||
130 | |||
131 | protected $dates = ['birthday', 'last_login']; |
||
132 | |||
133 | /** |
||
134 | * Scope to get all the social contacts |
||
135 | */ |
||
136 | private function scopeSocialLinks() |
||
140 | |||
141 | /** |
||
142 | * Scope do get all the contacts |
||
143 | */ |
||
144 | private function scopeContacts() |
||
148 | |||
149 | /** |
||
150 | * Scope do get all the contacts |
||
151 | */ |
||
152 | private function scopeProjects() |
||
156 | |||
157 | /** |
||
158 | * Scope do get all staff |
||
159 | */ |
||
160 | private function scopeStaff() |
||
164 | |||
165 | public static function getAllStaff() |
||
171 | |||
172 | /** |
||
173 | * Method to get all the social contacts |
||
174 | */ |
||
175 | public function socialLinks() |
||
179 | |||
180 | /** |
||
181 | * Method to get all the social contacts |
||
182 | */ |
||
183 | public function projects() |
||
187 | |||
188 | /** |
||
189 | * Method to get all the contacts. |
||
190 | */ |
||
191 | public function contacts() |
||
195 | |||
196 | public function status() |
||
213 | |||
214 | /** |
||
215 | * Returns an array of register column fields. |
||
216 | * |
||
217 | * @return array |
||
218 | */ |
||
219 | public function getRegisterFields() |
||
223 | |||
224 | /** |
||
225 | * The Groups relationship. |
||
226 | * |
||
227 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
228 | */ |
||
229 | public function groups() |
||
233 | |||
234 | /** |
||
235 | * The Menus relationship. |
||
236 | * |
||
237 | * @return List of \App\Menu |
||
238 | */ |
||
239 | public function menus($pos) |
||
248 | |||
249 | /** |
||
250 | * Returns the roles relationship. |
||
251 | * |
||
252 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
253 | */ |
||
254 | public function roles() |
||
258 | |||
259 | } |
||
260 |