| Conditions | 5 |
| Paths | 3 |
| Total Lines | 40 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 26 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | 2 | public function __invoke(Request $request) |
|
| 14 | { |
||
| 15 | /** @var RestrictedLink $restrictedLink */ |
||
| 16 | 2 | $restrictedLink = \LinkRestrictedAccess\RestrictedAccess::restrictedLinkModel()::query() |
|
| 17 | 2 | ->where('uuid', $request->route('uuid')) |
|
| 18 | 2 | ->firstOrFail(); |
|
| 19 | |||
| 20 | 2 | $request->validate([ |
|
| 21 | 2 | 'pin' => [ |
|
| 22 | 2 | 'required', |
|
| 23 | 2 | 'string', |
|
| 24 | 2 | 'max:100', |
|
| 25 | 2 | ], |
|
| 26 | 2 | ]); |
|
| 27 | |||
| 28 | if ( |
||
| 29 | 2 | $restrictedLink->checkPin && |
|
|
|
|||
| 30 | ( |
||
| 31 | 2 | !$restrictedLink->pin || |
|
| 32 | 2 | $restrictedLink->pin != $request->input('pin') |
|
| 33 | ) |
||
| 34 | |||
| 35 | ) { |
||
| 36 | 1 | throw ValidationException::withMessages([ |
|
| 37 | 1 | 'pin' => __('Incorrect pin'), |
|
| 38 | 1 | ]); |
|
| 39 | } |
||
| 40 | |||
| 41 | 2 | $message = __('Pin successful checked.'); |
|
| 42 | |||
| 43 | 2 | if ($request->expectsJson()) { |
|
| 44 | 1 | return Response::json([ |
|
| 45 | 1 | 'message' => $message, |
|
| 46 | 1 | 'data' => [ |
|
| 47 | 1 | 'success' => true, |
|
| 48 | 1 | ], |
|
| 49 | 1 | ]); |
|
| 50 | } |
||
| 51 | |||
| 52 | 1 | return Redirect::back()->with(['message' => $message]); |
|
| 53 | } |
||
| 55 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.