UserController::index()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pratiksh\Adminetic\Http\Controllers\Admin;
4
5
use App\Http\Controllers\Controller;
0 ignored issues
show
Bug introduced by
The type App\Http\Controllers\Controller was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use App\Models\User;
0 ignored issues
show
Bug introduced by
The type App\Models\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Pratiksh\Adminetic\Contracts\UserRepositoryInterface;
8
use Pratiksh\Adminetic\Http\Requests\UserRequest;
9
10
class UserController extends Controller
11
{
12
    protected $userRepositoryInterface;
13
14
    public function __construct(UserRepositoryInterface $userRepositoryInterface)
15
    {
16
        $this->userRepositoryInterface = $userRepositoryInterface;
17
        $this->authorizeResource(User::class, 'user');
18
    }
19
20
    /**
21
     * Display a listing of the resource.
22
     *
23
     * @return \Illuminate\Http\Response
24
     */
25
    public function index()
26
    {
27
        return view('adminetic::admin.user.index', $this->userRepositoryInterface->userIndex());
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('adminetic::...Interface->userIndex()) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
28
    }
29
30
    /**
31
     * Show the form for creating a new resource.
32
     *
33
     * @return \Illuminate\Http\Response
34
     */
35
    public function create()
36
    {
37
        return view('adminetic::admin.user.create', $this->userRepositoryInterface->userCreate());
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('adminetic::...nterface->userCreate()) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
38
    }
39
40
    /**
41
     * Store a newly created resource in storage.
42
     *
43
     * @param  \Pratiksh\Adminetic\Http\Requests\UserRequest  $request
44
     * @return \Illuminate\Http\Response
45
     */
46
    public function store(UserRequest $request)
47
    {
48
        $this->userRepositoryInterface->userStore($request);
49
50
        return redirect(adminRedirectRoute('user'))->withSuccess('User Created Sucessfully');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect(adminRed...r Created Sucessfully') also could return the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
51
    }
52
53
    /**
54
     * Display the specified resource.
55
     *
56
     * @param  \App\Models\User  $user
57
     * @return \Illuminate\Http\Response
58
     */
59
    public function show(User $user)
60
    {
61
        return view('adminetic::admin.profile.show', $this->userRepositoryInterface->userShow($user));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('adminetic::...rface->userShow($user)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
62
    }
63
64
    /**
65
     * Show the form for editing the specified resource.
66
     *
67
     * @param  \App\Models\User  $user
68
     * @return \Illuminate\Http\Response
69
     */
70
    public function edit(User $user)
71
    {
72
        return view('adminetic::admin.user.edit', $this->userRepositoryInterface->userEdit($user));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('adminetic::...rface->userEdit($user)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
73
    }
74
75
    /**
76
     * Update the specified resource in storage.
77
     *
78
     * @param  \Pratiksh\Adminetic\Http\Requests\UserRequest  $request
79
     * @param  \App\Models\User  $user
80
     * @return \Illuminate\Http\Response
81
     */
82
    public function update(UserRequest $request, User $user)
83
    {
84
        $this->userRepositoryInterface->userUpdate($request, $user);
85
86
        return request()->has('from_profile') ? redirect(adminEditRoute('profile', $user->profile->id))->withInfo('User Updated Sucessfully') : redirect(adminRedirectRoute('user'))->withInfo('User Updated Sucessfully');
0 ignored issues
show
Bug Best Practice introduced by
The expression return request()->has('f...r Updated Sucessfully') also could return the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
87
    }
88
89
    /**
90
     * Remove the specified resource from storage.
91
     *
92
     * @param  \App\Models\User  $user
93
     * @return \Illuminate\Http\Response
94
     */
95
    public function destroy(User $user)
96
    {
97
        $this->userRepositoryInterface->userDestroy($user);
98
99
        return redirect(adminRedirectRoute('user'))->withFail('User Deleted Sucessfully');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect(adminRed...r Deleted Sucessfully') also could return the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
100
    }
101
}
102