1 | <?php |
||||
2 | |||||
3 | namespace PWWEB\Localisation\Controllers\Tax; |
||||
4 | |||||
5 | use App\Http\Controllers\Controller; |
||||
6 | use Flash; |
||||
0 ignored issues
–
show
|
|||||
7 | use Illuminate\Http\Request; |
||||
8 | use PWWEB\Localisation\Enums\Tax\Type; |
||||
9 | use PWWEB\Localisation\Repositories\Tax\RateRepository; |
||||
10 | use PWWEB\Localisation\Requests\Tax\CreateRateRequest; |
||||
11 | use PWWEB\Localisation\Requests\Tax\UpdateRateRequest; |
||||
12 | |||||
13 | /** |
||||
14 | * PWWEB\Localisation\Controllers\Tax\RateController RateController. |
||||
15 | * |
||||
16 | * The CRUD controller for Rate |
||||
17 | * Class RateController |
||||
18 | * |
||||
19 | * @author Frank Pillukeit <[email protected]> |
||||
20 | * @author Richard Browne <[email protected] |
||||
21 | * @copyright 2020 pw-websolutions.com |
||||
22 | * @license http://www.opensource.org/licenses/mit-license.html MIT License |
||||
23 | */ |
||||
24 | class RateController extends Controller |
||||
25 | { |
||||
26 | /** |
||||
27 | * Repository of rates to be used throughout the controller. |
||||
28 | * |
||||
29 | * @var \PWWEB\Localisation\Repositories\Tax\RateRepository |
||||
30 | */ |
||||
31 | private $rateRepository; |
||||
32 | |||||
33 | /** |
||||
34 | * Constructor for the Rate controller. |
||||
35 | * |
||||
36 | * @param RateRepository $rateRepo Repository of Rates. |
||||
37 | */ |
||||
38 | public function __construct(RateRepository $rateRepo) |
||||
39 | { |
||||
40 | $this->rateRepository = $rateRepo; |
||||
41 | } |
||||
42 | |||||
43 | /** |
||||
44 | * Display a listing of the Rate. |
||||
45 | * |
||||
46 | * @param Request $request Index request |
||||
47 | * |
||||
48 | * @return \Illuminate\View\View |
||||
49 | */ |
||||
50 | public function index(Request $request) |
||||
51 | { |
||||
52 | $rates = $this->rateRepository->paginate(15); |
||||
53 | |||||
54 | return view('localisation::tax.rates.index') |
||||
55 | ->with('rates', $rates); |
||||
56 | } |
||||
57 | |||||
58 | /** |
||||
59 | * Show the form for creating a new Rate. |
||||
60 | * |
||||
61 | * @return \Illuminate\View\View |
||||
62 | */ |
||||
63 | public function create() |
||||
64 | { |
||||
65 | $types = Type::getAll(); |
||||
66 | |||||
67 | return view('localisation::tax.rates.create', compact('types')); |
||||
68 | } |
||||
69 | |||||
70 | /** |
||||
71 | * Store a newly created Rate in storage. |
||||
72 | * |
||||
73 | * @param CreateRateRequest $request Create Request |
||||
74 | * |
||||
75 | * @return \Illuminate\View\View |
||||
76 | */ |
||||
77 | public function store(CreateRateRequest $request) |
||||
78 | { |
||||
79 | $input = $request->all(); |
||||
80 | |||||
81 | $rate = $this->rateRepository->create($input); |
||||
0 ignored issues
–
show
|
|||||
82 | |||||
83 | Flash::success(__('pwweb::localisation.tax.rates.saved')); |
||||
84 | |||||
85 | return redirect(route('localisation.tax.rates.index')); |
||||
0 ignored issues
–
show
|
|||||
86 | } |
||||
87 | |||||
88 | /** |
||||
89 | * Display the specified Rate. |
||||
90 | * |
||||
91 | * @param int $id ID to show |
||||
92 | * |
||||
93 | * @return \Illuminate\View\View |
||||
94 | */ |
||||
95 | public function show($id) |
||||
96 | { |
||||
97 | $rate = $this->rateRepository->find($id); |
||||
98 | $rate->type = Type::make($rate->type); |
||||
0 ignored issues
–
show
It seems like
$rate->type can also be of type Illuminate\Database\Eloq...uent\Relations\Relation and Illuminate\Database\Eloquent\Relations\Relation ; however, parameter $value of Spatie\Enum\Enum::make() does only seem to accept integer|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
![]() |
|||||
99 | |||||
100 | if (true === empty($rate)) { |
||||
101 | Flash::error(__('pwweb::localisation.tax.rates.not_found')); |
||||
102 | |||||
103 | return redirect(route('localisation.tax.rates.index')); |
||||
0 ignored issues
–
show
|
|||||
104 | } |
||||
105 | |||||
106 | return view('localisation::tax.rates.show')->with('rate', $rate); |
||||
107 | } |
||||
108 | |||||
109 | /** |
||||
110 | * Show the form for editing the specified Rate. |
||||
111 | * |
||||
112 | * @param int $id ID to edit |
||||
113 | * |
||||
114 | * @return \Illuminate\View\View |
||||
115 | */ |
||||
116 | public function edit($id) |
||||
117 | { |
||||
118 | $rate = $this->rateRepository->find($id); |
||||
119 | $types = Type::getAll(); |
||||
120 | |||||
121 | if (true === empty($rate)) { |
||||
122 | Flash::error(__('pwweb::localisation.tax.rates.not_found')); |
||||
123 | |||||
124 | return redirect(route('localisation.tax.rates.index')); |
||||
0 ignored issues
–
show
|
|||||
125 | } |
||||
126 | |||||
127 | return view('localisation::tax.rates.edit', compact('rate', 'types')); |
||||
128 | } |
||||
129 | |||||
130 | /** |
||||
131 | * Update the specified Rate in storage. |
||||
132 | * |
||||
133 | * @param int $id ID to update |
||||
134 | * @param UpdateRateRequest $request Edit Request |
||||
135 | * |
||||
136 | * @return \Illuminate\View\View |
||||
137 | */ |
||||
138 | public function update($id, UpdateRateRequest $request) |
||||
139 | { |
||||
140 | $rate = $this->rateRepository->find($id); |
||||
141 | |||||
142 | if (true === empty($rate)) { |
||||
143 | Flash::error(__('pwweb::localisation.tax.rates.not_found')); |
||||
144 | |||||
145 | return redirect(route('localisation.tax.rates.index')); |
||||
0 ignored issues
–
show
|
|||||
146 | } |
||||
147 | |||||
148 | $rate = $this->rateRepository->update($request->all(), $id); |
||||
0 ignored issues
–
show
|
|||||
149 | |||||
150 | Flash::success(__('pwweb::localisation.tax.rates.updated')); |
||||
151 | |||||
152 | return redirect(route('localisation.tax.rates.index')); |
||||
0 ignored issues
–
show
|
|||||
153 | } |
||||
154 | |||||
155 | /** |
||||
156 | * Remove the specified Rate from storage. |
||||
157 | * |
||||
158 | * @param int $id ID to destroy |
||||
159 | * |
||||
160 | * @throws \Exception |
||||
161 | * |
||||
162 | * @return \Illuminate\View\View |
||||
163 | */ |
||||
164 | public function destroy($id) |
||||
165 | { |
||||
166 | $rate = $this->rateRepository->find($id); |
||||
167 | |||||
168 | if (true === empty($rate)) { |
||||
169 | Flash::error(__('pwweb::localisation.tax.rates.not_found')); |
||||
170 | |||||
171 | return redirect(route('localisation.tax.rates.index')); |
||||
0 ignored issues
–
show
|
|||||
172 | } |
||||
173 | |||||
174 | $this->rateRepository->delete($id); |
||||
175 | |||||
176 | Flash::success(__('pwweb::localisation.tax.rates.deleted')); |
||||
177 | |||||
178 | return redirect(route('localisation.tax.rates.index')); |
||||
0 ignored issues
–
show
|
|||||
179 | } |
||||
180 | } |
||||
181 |
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