| Conditions | 4 |
| Paths | 3 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function show() |
||
| 17 | { |
||
| 18 | //when code is found in DB |
||
| 19 | if (count(request()->segments()) == 1 && ($code = request()->segment(1))) { |
||
| 20 | $link = Link::byCode($code)->first(); |
||
| 21 | if ($link) { |
||
| 22 | $link->increment('used_count', 1); |
||
| 23 | $link->touchTimestamp('last_used'); |
||
| 24 | |||
| 25 | return redirect($link->original_url); //301 |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | //return VUE spa app |
||
| 30 | return view('shortener::shortener'); |
||
| 31 | } |
||
| 32 | } |
||
| 33 |