Completed
Pull Request — master (#87)
by Owen
02:01
created

helpers.php ➔ backpack_admin()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Returns the user instance if it exists
5
 * of the currently authenticated admin
6
 * based off the defined guard.
7
 */
8
if (!function_exists('backpack_admin')) {
9
    function backpack_admin()
10
    {
11
        if (config('backpack.base.separate_admin_session')) {
12
            $guard = config('backpack.base.admin_guard.name');
13
        } else {
14
            $guard = null;
15
        }
16
17
        return \Auth::guard($guard)->user();
18
    }
19
}
20
21
/*
22
 * Returns back a user instance without
23
 * the admin guard, however allows you
24
 * to pass in a custom guard if you like.
25
 */
26
if (!function_exists('backpack_user')) {
27
    function backpack_user($guard = null)
28
    {
29
        return \Auth::guard($guard)->user();
30
    }
31
}
32