DownloadController::store()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Adminetic\Website\Http\Controllers\Admin;
4
5
use Adminetic\Website\Contracts\DownloadRepositoryInterface;
6
use Adminetic\Website\Http\Requests\DownloadRequest;
7
use Adminetic\Website\Models\Admin\Download;
8
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...
9
10
class DownloadController extends Controller
11
{
12
    protected $downloadRepositoryInterface;
13
14
    public function __construct(DownloadRepositoryInterface $downloadRepositoryInterface)
15
    {
16
        $this->downloadRepositoryInterface = $downloadRepositoryInterface;
17
        $this->authorizeResource(Download::class, 'download');
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('website::admin.download.index', $this->downloadRepositoryInterface->indexDownload());
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::ad...rface->indexDownload()) 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('website::admin.download.create');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::admin.download.create') 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  \Adminetic\Website\Http\Requests\DownloadRequest  $request
44
     * @return \Illuminate\Http\Response
45
     */
46
    public function store(DownloadRequest $request)
47
    {
48
        $this->downloadRepositoryInterface->storeDownload($request);
49
50
        return redirect(adminRedirectRoute('download'))->withSuccess('Download 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('download'))->withSuccess('Download 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  \Adminetic\Website\Models\Admin\Download  $download
57
     * @return \Illuminate\Http\Response
58
     */
59
    public function show(Download $download)
60
    {
61
        return view('website::admin.download.show', $this->downloadRepositoryInterface->showDownload($download));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::ad...howDownload($download)) 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  \Adminetic\Website\Models\Admin\Download  $download
68
     * @return \Illuminate\Http\Response
69
     */
70
    public function edit(Download $download)
71
    {
72
        return view('website::admin.download.edit', $this->downloadRepositoryInterface->editDownload($download));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::ad...ditDownload($download)) 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  \Adminetic\Website\Http\Requests\DownloadRequest  $request
79
     * @param  \Adminetic\Website\Models\Admin\Download  $download
80
     * @return \Illuminate\Http\Response
81
     */
82
    public function update(DownloadRequest $request, Download $download)
83
    {
84
        $this->downloadRepositoryInterface->updateDownload($request, $download);
85
86
        return redirect(adminRedirectRoute('download'))->withInfo('Download Updated 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

86
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('download'))->withInfo('Download Updated Successfully.');
Loading history...
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...
87
    }
88
89
    /**
90
     * Remove the specified resource from storage.
91
     *
92
     * @param  \Adminetic\Website\Models\Admin\Download  $download
93
     * @return \Illuminate\Http\Response
94
     */
95
    public function destroy(Download $download)
96
    {
97
        $this->downloadRepositoryInterface->destroyDownload($download);
98
99
        return redirect(adminRedirectRoute('download'))->withFail('Download Deleted 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

99
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('download'))->withFail('Download Deleted Successfully.');
Loading history...
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...
100
    }
101
}
102