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