| Conditions | 3 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function create(Request $request): RedirectResponse |
||
| 19 | { |
||
| 20 | // Check if the article exist and if its display. |
||
| 21 | $article = Article::find($request->article_id); |
||
| 22 | |||
| 23 | if (is_null($article) || $article->is_display == false) { |
||
| 24 | return back() |
||
| 25 | ->withInput() |
||
| 26 | ->with('danger', 'This article doesn\'t exist or you can not reply to it !'); |
||
| 27 | } |
||
| 28 | |||
| 29 | CommentValidator::create($request->all())->validate(); |
||
| 30 | CommentRepository::create($request->all(), auth()->user()); |
||
|
|
|||
| 31 | |||
| 32 | return back() |
||
| 33 | ->with('success', 'Your comment has been posted successfully !'); |
||
| 34 | } |
||
| 35 | } |
||
| 36 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: