ContactController   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 109
rs 10
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 4 1
A import() 0 4 1
A index() 0 3 1
A destroy() 0 4 1
A update() 0 4 1
A edit() 0 3 1
A __construct() 0 4 1
A export() 0 3 1
A show() 0 3 1
A create() 0 3 1
1
<?php
2
3
namespace Adminetic\Contact\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 Maatwebsite\Excel\Facades\Excel;
7
use Adminetic\Contact\Models\Admin\Contact;
8
use Adminetic\Contact\Exports\ContactsExport;
9
use Adminetic\Contact\Imports\ContactsImport;
10
use Adminetic\Contact\Http\Requests\ContactRequest;
11
use Adminetic\Contact\Contracts\ContactRepositoryInterface;
12
13
14
15
class ContactController extends Controller
16
{
17
    protected $contactRepositoryInterface;
18
19
    public function __construct(ContactRepositoryInterface $contactRepositoryInterface)
20
    {
21
        $this->contactRepositoryInterface = $contactRepositoryInterface;
22
        $this->authorizeResource(Contact::class, 'contact');
23
    }
24
25
26
    /**
27
     * Display a listing of the resource.
28
     *
29
     * @return \Illuminate\Http\Response
30
     */
31
    public function index()
32
    {
33
        return view('contact::admin.contact.index', $this->contactRepositoryInterface->indexContact());
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('contact::ad...erface->indexContact()) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
34
    }
35
36
    /**
37
     * Show the form for creating a new resource.
38
     *
39
     * @return \Illuminate\Http\Response
40
     */
41
    public function create()
42
    {
43
        return view('contact::admin.contact.create');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('contact::admin.contact.create') returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
44
    }
45
46
    /**
47
     * Store a newly created resource in storage.
48
     *
49
     * @param  \Adminetic\Contact\Http\Requests\ContactRequest  $request
50
     * @return \Illuminate\Http\Response
51
     */
52
    public function store(ContactRequest $request)
53
    {
54
        $this->contactRepositoryInterface->storeContact($request);
55
        return redirect(adminRedirectRoute('contact'))->withSuccess('Contact Created Successfully.');
0 ignored issues
show
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...
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

55
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('contact'))->withSuccess('Contact Created Successfully.');
Loading history...
56
    }
57
58
    /**
59
     * Display the specified resource.
60
     *
61
     * @param  \Adminetic\Contact\Models\Admin\Contact  $contact
62
     * @return \Illuminate\Http\Response
63
     */
64
    public function show(Contact $contact)
65
    {
66
        return view('contact::admin.contact.show', $this->contactRepositoryInterface->showContact($contact));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('contact::ad...>showContact($contact)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
67
    }
68
69
    /**
70
     * Show the form for editing the specified resource.
71
     *
72
     * @param  \Adminetic\Contact\Models\Admin\Contact  $contact
73
     * @return \Illuminate\Http\Response
74
     */
75
    public function edit(Contact $contact)
76
    {
77
        return view('contact::admin.contact.edit', $this->contactRepositoryInterface->editContact($contact));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('contact::ad...>editContact($contact)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
78
    }
79
80
    /**
81
     * Update the specified resource in storage.
82
     *
83
     * @param  \Adminetic\Contact\Http\Requests\ContactRequest  $request
84
     * @param  \Adminetic\Contact\Models\Admin\Contact  $contact
85
     * @return \Illuminate\Http\Response
86
     */
87
    public function update(ContactRequest $request, Contact $contact)
88
    {
89
        $this->contactRepositoryInterface->updateContact($request, $contact);
90
        return redirect(adminRedirectRoute('contact'))->withInfo('Contact 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

90
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('contact'))->withInfo('Contact 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...
91
    }
92
93
    /**
94
     * Remove the specified resource from storage.
95
     *
96
     * @param  \Adminetic\Contact\Models\Admin\Contact  $contact
97
     * @return \Illuminate\Http\Response
98
     */
99
    public function destroy(Contact $contact)
100
    {
101
        $this->contactRepositoryInterface->destroyContact($contact);
102
        return redirect(adminRedirectRoute('contact'))->withFail('Contact 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

102
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('contact'))->withFail('Contact 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...
103
    }
104
105
    /**
106
     *
107
     * Import Contacts
108
     *
109
     */
110
    public function import()
111
    {
112
        Excel::import(new ContactsImport, request()->file('contacts_import'));
0 ignored issues
show
Bug introduced by
It seems like request()->file('contacts_import') can also be of type Illuminate\Http\UploadedFile[] and array; however, parameter $filePath of Maatwebsite\Excel\Facades\Excel::import() does only seem to accept Illuminate\Http\UploadedFile|string, maybe add an additional type check? ( Ignorable by Annotation )

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

112
        Excel::import(new ContactsImport, /** @scrutinizer ignore-type */ request()->file('contacts_import'));
Loading history...
113
        return redirect(adminRedirectRoute('contact'))->withSuccess('Contacts Imported.');
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

113
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('contact'))->withSuccess('Contacts Imported.');
Loading history...
114
    }
115
116
    /**
117
     *
118
     * Export Contacts
119
     *
120
     */
121
    public function export()
122
    {
123
        return Excel::download(new ContactsExport, 'contacts.xlsx');
124
    }
125
}
126