Completed
Push — master ( a6330b...b11988 )
by wen
06:59
created

PHPVarToJavaScript::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 11
nc 1
nop 2
1
<?php
2
3
4
namespace Sco\Admin\Http\Middleware;
5
6
use Auth;
7
use Illuminate\Http\Request;
8
9
class PHPVarToJavaScript
10
{
11
    public function handle(Request $request, \Closure $next)
12
    {
13
        config([
14
            'javascript.bind_js_vars_to_this_view' => 'admin::partials.head',
15
        ]);
16
        JavaScript::put([
17
            'Lang' => config('app.locale'),
18
            'LoggedUser' => [
19
                'id' => Auth::id(),
20
                'name' => Auth::user()->name,
21
                'role' => Auth::user()->roles->makeHidden(['description', 'created_at', 'updated_at', 'pivot', 'perms'])->first(null, collect())
22
            ],
23
            'PermList' => request()->attributes->get('admin.permissions', collect())
24
        ]);
25
        return $next($request);
26
    }
27
28
}
29