|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
if (!function_exists('backpack_url')) { |
|
4
|
|
|
/** |
|
5
|
|
|
* Appends the configured backpack prefix and returns |
|
6
|
|
|
* the URL using the standard Laravel helpers. |
|
7
|
|
|
* |
|
8
|
|
|
* @param $path |
|
9
|
|
|
* |
|
10
|
|
|
* @return string |
|
11
|
|
|
*/ |
|
12
|
|
|
function backpack_url($path = null) |
|
13
|
|
|
{ |
|
14
|
|
|
$path = !$path || (substr($path, 1, 1) == '/') ? $path : '/'.$path; |
|
15
|
|
|
|
|
16
|
|
|
return url(config('backpack.base.route_prefix', 'admin').$path); |
|
17
|
|
|
} |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
if (!function_exists('backpack_authentication_column')) { |
|
21
|
|
|
/** |
|
22
|
|
|
* Return the username column name. |
|
23
|
|
|
* The Laravel default (and Backpack default) is 'email'. |
|
24
|
|
|
* |
|
25
|
|
|
* @return string |
|
26
|
|
|
*/ |
|
27
|
|
|
function backpack_authentication_column() |
|
28
|
|
|
{ |
|
29
|
|
|
return config('backpack.base.authentication_column', 'email'); |
|
30
|
|
|
} |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
if (!function_exists('backpack_users_have_email')) { |
|
34
|
|
|
/** |
|
35
|
|
|
* Check if the email column is present on the user table. |
|
36
|
|
|
* |
|
37
|
|
|
* @return string |
|
38
|
|
|
*/ |
|
39
|
|
|
function backpack_users_have_email() |
|
40
|
|
|
{ |
|
41
|
|
|
$user_model_fqn = config('backpack.base.user_model_fqn'); |
|
42
|
|
|
$user = new $user_model_fqn(); |
|
43
|
|
|
|
|
44
|
|
|
return \Schema::hasColumn($user->getTable(), 'email'); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
if (!function_exists('backpack_avatar')) { |
|
49
|
|
|
/** |
|
50
|
|
|
* Returns the avatar URL of a user. |
|
51
|
|
|
* |
|
52
|
|
|
* @param $user |
|
53
|
|
|
* |
|
54
|
|
|
* @return string |
|
55
|
|
|
*/ |
|
56
|
|
|
function backpack_avatar_url($user) |
|
57
|
|
|
{ |
|
58
|
|
|
$placehold = 'https://placehold.it/160x160/00a65a/ffffff/&text='.$user->name[0]; |
|
59
|
|
|
|
|
60
|
|
|
switch (config('backpack.base.avatar_type')) { |
|
61
|
|
|
case 'gravatar': |
|
62
|
|
|
if (config('backpack.base.authentication_column') == 'email') { |
|
63
|
|
|
return Gravatar::fallback('https://placehold.it/160x160/00a65a/ffffff/&text='.$user->name[0])->get($user->email); |
|
64
|
|
|
} else { |
|
65
|
|
|
return $placehold; |
|
66
|
|
|
} |
|
67
|
|
|
break; |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
case 'placehold': |
|
70
|
|
|
return $placehold; |
|
71
|
|
|
break; |
|
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
default: |
|
74
|
|
|
return $user->{config('backpack.base.avatar_type')}; |
|
75
|
|
|
break; |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return,dieorexitstatements that have been added for debug purposes.In the above example, the last
return falsewill never be executed, because a return statement has already been met in every possible execution path.