Conditions | 1 |
Paths | 1 |
Total Lines | 20 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | public function store(Request $request) { |
||
15 | // ... |
||
16 | // validation can be done here before saving |
||
17 | // with $this->validate($request, $rules) |
||
|
|||
18 | // ... |
||
19 | |||
20 | // get data to save in an associative array using $request->only() |
||
21 | $data = $request->only(['title', 'description']); |
||
22 | |||
23 | // save post and assign return value of created post to $post array |
||
24 | $post = Post::create($data); |
||
25 | |||
26 | // fire PostPublished event after post is successfully added to database |
||
27 | event(new PostPublished($post)); |
||
28 | // or |
||
29 | // \Event::fire(new PostPublished($post)) |
||
30 | |||
31 | // return post as response, Laravel automatically serializes this to JSON |
||
32 | return response($post, 201); |
||
33 | } |
||
34 | } |
||
35 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.