1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PWWEB\Localisation\Controllers\Address; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
6
|
|
|
use Flash; |
|
|
|
|
7
|
|
|
use Illuminate\Http\RedirectResponse; |
8
|
|
|
use Illuminate\Http\Request; |
9
|
|
|
use Illuminate\View\View; |
10
|
|
|
use PWWEB\Localisation\Repositories\Address\TypeRepository; |
11
|
|
|
use PWWEB\Localisation\Requests\Address\CreateTypeRequest; |
12
|
|
|
use PWWEB\Localisation\Requests\Address\UpdateTypeRequest; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* PWWEB\Localisation\Controllers\Address\TypeController TypeController. |
16
|
|
|
* |
17
|
|
|
* The CRUD controller for Type |
18
|
|
|
* Class TypeController |
19
|
|
|
* |
20
|
|
|
* @author Frank Pillukeit <[email protected]> |
21
|
|
|
* @author Richard Browne <[email protected]> |
22
|
|
|
* @copyright 2020 pw-websolutions.com |
23
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License |
24
|
|
|
*/ |
25
|
|
|
class TypeController extends Controller |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* Repository of Address types to be used throughout the controller. |
29
|
|
|
* |
30
|
|
|
* @var TypeRepository |
31
|
|
|
*/ |
32
|
|
|
private $typeRepository; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Constructor for the Address type controller. |
36
|
|
|
* |
37
|
|
|
* @param \PWWEB\Localisation\Repositories\Address\TypeRepository $typeRepo Repository of Address types |
38
|
|
|
*/ |
39
|
|
|
public function __construct(TypeRepository $typeRepo) |
40
|
|
|
{ |
41
|
|
|
$this->typeRepository = $typeRepo; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Display a listing of the Address type. |
46
|
|
|
* |
47
|
|
|
* @param Request $request Request containing the information for filtering. |
48
|
|
|
* |
49
|
|
|
* @return \Illuminate\View\View |
50
|
|
|
*/ |
51
|
|
|
public function index(Request $request): View |
52
|
|
|
{ |
53
|
|
|
$types = $this->typeRepository->all(); |
54
|
|
|
|
55
|
|
|
return view('localisation::addresses.types.index') |
56
|
|
|
->with('types', $types); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Show the form for creating a new Address type. |
61
|
|
|
* |
62
|
|
|
* @return \Illuminate\View\View |
63
|
|
|
*/ |
64
|
|
|
public function create(): View |
65
|
|
|
{ |
66
|
|
|
return view('localisation::addresses.types.create'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Store a newly created Address type in storage. |
71
|
|
|
* |
72
|
|
|
* @param CreateTypeRequest $request Request containing the information to be stored. |
73
|
|
|
* |
74
|
|
|
* @return \Illuminate\Http\RedirectResponse |
75
|
|
|
*/ |
76
|
|
|
public function store(CreateTypeRequest $request): RedirectResponse |
77
|
|
|
{ |
78
|
|
|
$input = $request->all(); |
79
|
|
|
|
80
|
|
|
$type = $this->typeRepository->create($input); |
|
|
|
|
81
|
|
|
|
82
|
|
|
Flash::success('Type saved successfully.'); |
83
|
|
|
|
84
|
|
|
return redirect(route('localisation.address.types.index')); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Display the specified Address type. |
89
|
|
|
* |
90
|
|
|
* @param int $id ID of the Address type to be displayed. Used for retrieving currently held data. |
91
|
|
|
* |
92
|
|
|
* @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse |
93
|
|
|
*/ |
94
|
|
|
public function show($id) |
95
|
|
|
{ |
96
|
|
|
$type = $this->typeRepository->find($id); |
97
|
|
|
|
98
|
|
|
if (true === empty($type)) { |
99
|
|
|
Flash::error('Type not found'); |
100
|
|
|
|
101
|
|
|
return redirect(route('localisation.address.types.index')); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
return view('localisation::addresses.types.show')->with('type', $type); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Show the form for editing the specified Address type. |
109
|
|
|
* |
110
|
|
|
* @param int $id ID of the Address type to be edited. Used for retrieving currently held data. |
111
|
|
|
* |
112
|
|
|
* @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse |
113
|
|
|
*/ |
114
|
|
|
public function edit($id) |
115
|
|
|
{ |
116
|
|
|
$type = $this->typeRepository->find($id); |
117
|
|
|
|
118
|
|
|
if (true === empty($type)) { |
119
|
|
|
Flash::error('Type not found'); |
120
|
|
|
|
121
|
|
|
return redirect(route('localisation.address.types.index')); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
return view('localisation::addresses.types.edit')->with('type', $type); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Update the specified Address type in storage. |
129
|
|
|
* |
130
|
|
|
* @param int $id ID of the Address type to be updated. |
131
|
|
|
* @param UpdateTypeRequest $request Request containing the information to be updated. |
132
|
|
|
* |
133
|
|
|
* @return \Illuminate\Http\RedirectResponse |
134
|
|
|
*/ |
135
|
|
|
public function update($id, UpdateTypeRequest $request): RedirectResponse |
136
|
|
|
{ |
137
|
|
|
$type = $this->typeRepository->find($id); |
138
|
|
|
|
139
|
|
|
if (true === empty($type)) { |
140
|
|
|
Flash::error('Type not found'); |
141
|
|
|
|
142
|
|
|
return redirect(route('localisation.address.types.index')); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
$type = $this->typeRepository->update($request->all(), $id); |
|
|
|
|
146
|
|
|
|
147
|
|
|
Flash::success('Type updated successfully.'); |
148
|
|
|
|
149
|
|
|
return redirect(route('localisation.address.types.index')); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Remove the specified Address type from storage. |
154
|
|
|
* |
155
|
|
|
* @param int $id ID of the Address type to be destroyed. |
156
|
|
|
* |
157
|
|
|
* @throws \Exception |
158
|
|
|
* |
159
|
|
|
* @return \Illuminate\Http\RedirectResponse |
160
|
|
|
*/ |
161
|
|
|
public function destroy($id): RedirectResponse |
162
|
|
|
{ |
163
|
|
|
$type = $this->typeRepository->find($id); |
164
|
|
|
|
165
|
|
|
if (true === empty($type)) { |
166
|
|
|
Flash::error('Type not found'); |
167
|
|
|
|
168
|
|
|
return redirect(route('localisation.address.types.index')); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
$this->typeRepository->delete($id); |
172
|
|
|
|
173
|
|
|
Flash::success('Type deleted successfully.'); |
174
|
|
|
|
175
|
|
|
return redirect(route('localisation.address.types.index')); |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths