Passed
Pull Request — main (#31)
by PRATIK
04:05
created

HistoryController   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
c 1
b 0
f 1
dl 0
loc 88
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 4 1
A __construct() 0 4 1
A show() 0 3 1
A index() 0 3 1
A destroy() 0 4 1
A update() 0 4 1
A edit() 0 3 1
A create() 0 3 1
1
<?php
2
3
namespace Adminetic\Website\Http\Controllers\Admin;
4
5
use Adminetic\Website\Models\Admin\History;
6
use Adminetic\Website\Http\Requests\HistoryRequest;
7
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...
8
use Adminetic\Website\Contracts\HistoryRepositoryInterface;
9
10
class HistoryController extends Controller
11
{
12
    protected $historyRepositoryInterface;
13
14
    public function __construct(HistoryRepositoryInterface $historyRepositoryInterface)
15
    {
16
        $this->historyRepositoryInterface = $historyRepositoryInterface;
17
        $this->authorizeResource(History::class, 'history');
18
    }
19
20
21
    /**
22
     * Display a listing of the resource.
23
     *
24
     * @return \Illuminate\Http\Response
25
     */
26
    public function index()
27
    {
28
        return view('website::admin.history.index', $this->historyRepositoryInterface->indexHistory());
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::ad...erface->indexHistory()) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
29
    }
30
31
    /**
32
     * Show the form for creating a new resource.
33
     *
34
     * @return \Illuminate\Http\Response
35
     */
36
    public function create()
37
    {
38
        return view('website::admin.history.create');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::admin.history.create') returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
39
    }
40
41
    /**
42
     * Store a newly created resource in storage.
43
     *
44
     * @param  \App\Http\Requests\HistoryRequest  $request
0 ignored issues
show
Bug introduced by
The type App\Http\Requests\HistoryRequest 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...
45
     * @return \Illuminate\Http\Response
46
     */
47
    public function store(HistoryRequest $request)
48
    {
49
        $this->historyRepositoryInterface->storeHistory($request);
50
        return redirect(adminRedirectRoute('history'))->withSuccess('History Created Successfully.');
0 ignored issues
show
Bug introduced by
The function adminRedirectRoute was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('history'))->withSuccess('History Created Successfully.');
Loading history...
Bug Best Practice introduced by
The expression return redirect(adminRed...Created Successfully.') also could return the type Illuminate\Http\Redirect...nate\Routing\Redirector 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\Admin\History  $history
0 ignored issues
show
Bug introduced by
The type App\Models\Admin\History 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...
57
     * @return \Illuminate\Http\Response
58
     */
59
    public function show(History $history)
60
    {
61
        return view('website::admin.history.show', $this->historyRepositoryInterface->showHistory($history));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::ad...>showHistory($history)) 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\Admin\History  $history
68
     * @return \Illuminate\Http\Response
69
     */
70
    public function edit(History $history)
71
    {
72
        return view('website::admin.history.edit', $this->historyRepositoryInterface->editHistory($history));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::ad...>editHistory($history)) 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  \App\Http\Requests\HistoryRequest  $request
79
     * @param  \App\Models\Admin\History  $history
80
     * @return \Illuminate\Http\Response
81
     */
82
    public function update(HistoryRequest $request, History $history)
83
    {
84
        $this->historyRepositoryInterface->updateHistory($request, $history);
85
        return redirect(adminRedirectRoute('history'))->withInfo('History Updated Successfully.');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect(adminRed...Updated Successfully.') also could return the type Illuminate\Http\Redirect...nate\Routing\Redirector which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Bug introduced by
The function adminRedirectRoute was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

85
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('history'))->withInfo('History Updated Successfully.');
Loading history...
86
    }
87
88
    /**
89
     * Remove the specified resource from storage.
90
     *
91
     * @param  \App\Models\Admin\History  $history
92
     * @return \Illuminate\Http\Response
93
     */
94
    public function destroy(History $history)
95
    {
96
        $this->historyRepositoryInterface->destroyHistory($history);
97
        return redirect(adminRedirectRoute('history'))->withFail('History Deleted Successfully.');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect(adminRed...Deleted Successfully.') also could return the type Illuminate\Http\Redirect...nate\Routing\Redirector which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Bug introduced by
The function adminRedirectRoute was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

97
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('history'))->withFail('History Deleted Successfully.');
Loading history...
98
    }
99
}
100