Passed
Pull Request — master (#53)
by
unknown
05:24
created

ImpersonateController::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\User;
6
use Illuminate\Http\Request;
7
use Illuminate\Support\Facades\Auth;
8
9
class ImpersonateController extends Controller
10
{
11
    /**
12
     * Display a listing of the resource.
13
     *
14
     */
15
    public function create()
16
    {
17
        return view('impersonate.create');
18
    }
19
20
21
    public function store(Request $request)
22
    {
23
        $id = $request->id;
24
        $email = $request->email;
25
        if ($id != null) {
26
            $user = User::findOrFail($id);
27
        } else {
28
            $user = User::where('email', $email)->firstOrFail();
29
        }
30
31
32
        Auth::user()->impersonate($user);
33
        return redirect("/");
34
    }
35
}
36