|
7 | 7 | use Cohensive\OEmbed\Facades\OEmbed;
|
8 | 8 | use Illuminate\Support\Facades\Schema;
|
9 | 9 | use Illuminate\Support\Facades\Route;
|
| 10 | +use Illuminate\Support\Facades\Response; |
10 | 11 | use JeroenDesloovere\VCard\VCard;
|
11 | 12 |
|
12 | 13 | use Auth;
|
@@ -479,25 +480,21 @@ public function clickNumber(request $request)
|
479 | 480 | }
|
480 | 481 |
|
481 | 482 | //Download Vcard
|
482 |
| - public function vcard(Request $request) |
| 483 | + public function vcard(request $request) |
483 | 484 | {
|
484 | 485 | $linkId = $request->id;
|
485 |
| - $link = Link::findOrFail($linkId); // find the link with the given ID or throw an exception |
486 |
| - $buttonValue = $link->button_value; |
487 |
| - $content = $link->content; |
488 | 486 |
|
489 |
| - Link::where('id', $linkId)->increment('click_number', 1); |
| 487 | + // Find the link with the specified ID |
| 488 | + $link = Link::findOrFail($linkId); |
490 | 489 |
|
491 |
| - // build the vCard string |
492 |
| - $vCard = "BEGIN:VCARD\r\nVERSION:3.0\r\n"; |
493 |
| - $vCard .= "FN:$buttonValue\r\n"; |
494 |
| - $vCard .= "NOTE:$content\r\n"; |
495 |
| - $vCard .= "END:VCARD\r\n"; |
| 490 | + // Set the response headers to indicate that a VCard file should be downloaded |
| 491 | + $headers = [ |
| 492 | + 'Content-Type' => 'text/vcard', |
| 493 | + 'Content-Disposition' => 'attachment; filename="vcard.vcf"', |
| 494 | + ]; |
496 | 495 |
|
497 |
| - // return the vCard content as a downloadable response |
498 |
| - return response($vCard) |
499 |
| - ->header('Content-Type', 'text/vcard') |
500 |
| - ->header('Content-Disposition', 'attachment; filename=vcard.vcf'); |
| 496 | + // Return the link's content as a downloadable file |
| 497 | + return Response::make($link->link, 200, $headers); |
501 | 498 | }
|
502 | 499 |
|
503 | 500 | //Show link, click number, up link in links page
|
|
0 commit comments