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

ImpersonateController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 25
ccs 0
cts 15
cp 0
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 13 2
A create() 0 3 1
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