Conditions | 3 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4.125 |
Changes | 2 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
24 | 2 | public static function createUser($attributes) |
|
25 | { |
||
26 | 2 | $user = User::where(['email' => $attributes['email']])->withTrashed()->first(); |
|
27 | |||
28 | 2 | if ($user == null) { |
|
29 | $password = str_random(8); |
||
30 | $user = User::create([ |
||
31 | 'firstname' => $attributes['firstname'], |
||
32 | 'lastname' => $attributes['lastname'], |
||
33 | 'name' => $attributes['name'], |
||
34 | 'email' => $attributes['email'] |
||
35 | ]); |
||
36 | $user->clearPassword = $password; |
||
37 | } |
||
38 | // If user is deleted, this is restoring the user only, but not his asset ( tournaments, categories, etc.) |
||
39 | 2 | if ($user->isDeleted()) { |
|
40 | 1 | $user->deleted_at = null; |
|
41 | 1 | $user->save(); |
|
42 | } |
||
43 | 2 | return $user; |
|
44 | } |
||
46 |