Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
28 | 4 | public function postOrder(Request $request) |
|
29 | { |
||
30 | 4 | $ids = $request->input('ids'); |
|
31 | |||
32 | 4 | $order = 1; |
|
33 | 4 | foreach ($ids as $id) { |
|
34 | 4 | $instance = $this->model->find($id); |
|
35 | 4 | if (! empty($instance)) { |
|
36 | 4 | $instance->{$this->model->orderFieldName()} = $order; |
|
37 | 4 | $instance->save(); |
|
38 | 4 | $order++; |
|
39 | } |
||
40 | } |
||
41 | |||
42 | 4 | return response()->json(['error' => false]); |
|
43 | } |
||
44 | } |
||
45 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: