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

helpers.php ➔ backpack_user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
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