|
7 | 7 | use Cohensive\OEmbed\Facades\OEmbed;
|
8 | 8 | use Illuminate\Support\Facades\Schema;
|
9 | 9 | use Illuminate\Support\Facades\Route;
|
| 10 | +use JeroenDesloovere\VCard\VCard; |
10 | 11 |
|
11 | 12 | use Auth;
|
12 | 13 | use DB;
|
@@ -144,6 +145,8 @@ public function AddUpdateLink($id = 0)
|
144 | 145 | $data['linkTypeID'] = "6";
|
145 | 146 | } elseif ($bid == 44) {
|
146 | 147 | $data['linkTypeID'] = "7";
|
| 148 | + } elseif ($bid == 96) { |
| 149 | + $data['linkTypeID'] = "8"; |
147 | 150 | } else {
|
148 | 151 | $data['linkTypeID'] = "1";
|
149 | 152 | }
|
@@ -245,6 +248,69 @@ public function saveLink(request $request)
|
245 | 248 | 'button_id' => $button?->id,
|
246 | 249 | 'title' => $LinkTitle,
|
247 | 250 | ]);
|
| 251 | + }elseif($linkType->typename == "vcard"){ |
| 252 | + |
| 253 | + $prefix = $request->input('prefix'); |
| 254 | + $firstName = $request->input('first_name'); |
| 255 | + $middleName = $request->input('middle_name'); |
| 256 | + $lastName = $request->input('last_name'); |
| 257 | + $suffix = $request->input('suffix'); |
| 258 | + $nickname = $request->input('nickname'); |
| 259 | + $organization = $request->input('organization'); |
| 260 | + $title = $request->input('title'); |
| 261 | + $role = $request->input('role'); |
| 262 | + $workUrl = $request->input('work_url'); |
| 263 | + $email = $request->input('email'); |
| 264 | + $workEmail = $request->input('work_email'); |
| 265 | + $homePhone = $request->input('home_phone'); |
| 266 | + $workPhone = $request->input('work_phone'); |
| 267 | + $cellPhone = $request->input('cell_phone'); |
| 268 | + $homeAddressLabel = $request->input('home_address_label'); |
| 269 | + $homeAddressStreet = $request->input('home_address_street'); |
| 270 | + $homeAddressCity = $request->input('home_address_city'); |
| 271 | + $homeAddressState = $request->input('home_address_state'); |
| 272 | + $homeAddressZip = $request->input('home_address_zip'); |
| 273 | + $homeAddressCountry = $request->input('home_address_country'); |
| 274 | + $workAddressLabel = $request->input('work_address_label'); |
| 275 | + $workAddressStreet = $request->input('work_address_street'); |
| 276 | + $workAddressCity = $request->input('work_address_city'); |
| 277 | + $workAddressState = $request->input('work_address_state'); |
| 278 | + $workAddressZip = $request->input('work_address_zip'); |
| 279 | + $workAddressCountry = $request->input('work_address_country'); |
| 280 | + |
| 281 | + // Create a new vCard instance |
| 282 | + $vCard = new VCard(); |
| 283 | + |
| 284 | + // Set the personal information |
| 285 | + $vCard->addName($lastName, $firstName, $middleName, $prefix, $suffix); |
| 286 | + $vCard->addRole($role); |
| 287 | + |
| 288 | + // Set the organization information |
| 289 | + $vCard->addCompany($organization); |
| 290 | + $vCard->addJobtitle($title); |
| 291 | + $vCard->addUrl($workUrl); |
| 292 | + |
| 293 | + // Set the phone numbers |
| 294 | + $vCard->addPhoneNumber($homePhone, 'HOME'); |
| 295 | + $vCard->addPhoneNumber($workPhone, 'WORK'); |
| 296 | + $vCard->addPhoneNumber($cellPhone, 'CELL'); |
| 297 | + |
| 298 | + // Set the email addresses |
| 299 | + $vCard->addEmail($email, 'HOME'); |
| 300 | + $vCard->addEmail($workEmail, 'WORK'); |
| 301 | + |
| 302 | + // Set the addresses |
| 303 | + $vCard->addAddress($homeAddressStreet, null, null, $homeAddressCity, $homeAddressState, $homeAddressZip, $homeAddressCountry, 'HOME', $homeAddressLabel); |
| 304 | + $vCard->addAddress($workAddressStreet, null, null, $workAddressCity, $workAddressState, $workAddressZip, $workAddressCountry, 'WORK', $workAddressLabel); |
| 305 | + |
| 306 | + // Generate the vCard file content |
| 307 | + $LinkURL = $vCard->getOutput(); |
| 308 | + |
| 309 | + $OrigLink->update([ |
| 310 | + 'link' => $LinkURL, |
| 311 | + 'button_id' => 96, |
| 312 | + 'title' => $LinkTitle, |
| 313 | + ]); |
248 | 314 | }else{
|
249 | 315 | $OrigLink->update([
|
250 | 316 | 'link' => $LinkURL,
|
@@ -286,6 +352,65 @@ public function saveLink(request $request)
|
286 | 352 | }elseif($linkType->typename == "telephone"){
|
287 | 353 | $links->link = "tel:".$links->link;
|
288 | 354 | $links->button_id = $button?->id;
|
| 355 | + }elseif($linkType->typename == "vcard"){ |
| 356 | + |
| 357 | + $prefix = $request->input('prefix'); |
| 358 | + $firstName = $request->input('first_name'); |
| 359 | + $middleName = $request->input('middle_name'); |
| 360 | + $lastName = $request->input('last_name'); |
| 361 | + $suffix = $request->input('suffix'); |
| 362 | + $nickname = $request->input('nickname'); |
| 363 | + $organization = $request->input('organization'); |
| 364 | + $title = $request->input('title'); |
| 365 | + $role = $request->input('role'); |
| 366 | + $workUrl = $request->input('work_url'); |
| 367 | + $email = $request->input('email'); |
| 368 | + $workEmail = $request->input('work_email'); |
| 369 | + $homePhone = $request->input('home_phone'); |
| 370 | + $workPhone = $request->input('work_phone'); |
| 371 | + $cellPhone = $request->input('cell_phone'); |
| 372 | + $homeAddressLabel = $request->input('home_address_label'); |
| 373 | + $homeAddressStreet = $request->input('home_address_street'); |
| 374 | + $homeAddressCity = $request->input('home_address_city'); |
| 375 | + $homeAddressState = $request->input('home_address_state'); |
| 376 | + $homeAddressZip = $request->input('home_address_zip'); |
| 377 | + $homeAddressCountry = $request->input('home_address_country'); |
| 378 | + $workAddressLabel = $request->input('work_address_label'); |
| 379 | + $workAddressStreet = $request->input('work_address_street'); |
| 380 | + $workAddressCity = $request->input('work_address_city'); |
| 381 | + $workAddressState = $request->input('work_address_state'); |
| 382 | + $workAddressZip = $request->input('work_address_zip'); |
| 383 | + $workAddressCountry = $request->input('work_address_country'); |
| 384 | + |
| 385 | + // Create a new vCard instance |
| 386 | + $vCard = new VCard(); |
| 387 | + |
| 388 | + // Set the personal information |
| 389 | + $vCard->addName($lastName, $firstName, $middleName, $prefix, $suffix); |
| 390 | + $vCard->addRole($role); |
| 391 | + |
| 392 | + // Set the organization information |
| 393 | + $vCard->addCompany($organization); |
| 394 | + $vCard->addJobtitle($title); |
| 395 | + $vCard->addUrl($workUrl); |
| 396 | + |
| 397 | + // Set the phone numbers |
| 398 | + $vCard->addPhoneNumber($homePhone, 'HOME'); |
| 399 | + $vCard->addPhoneNumber($workPhone, 'WORK'); |
| 400 | + $vCard->addPhoneNumber($cellPhone, 'CELL'); |
| 401 | + |
| 402 | + // Set the email addresses |
| 403 | + $vCard->addEmail($email, 'HOME'); |
| 404 | + $vCard->addEmail($workEmail, 'WORK'); |
| 405 | + |
| 406 | + // Set the addresses |
| 407 | + $vCard->addAddress($homeAddressStreet, null, null, $homeAddressCity, $homeAddressState, $homeAddressZip, $homeAddressCountry, 'HOME', $homeAddressLabel); |
| 408 | + $vCard->addAddress($workAddressStreet, null, null, $workAddressCity, $workAddressState, $workAddressZip, $workAddressCountry, 'WORK', $workAddressLabel); |
| 409 | + |
| 410 | + // Generate the vCard file content |
| 411 | + $links->link = $vCard->getOutput(); |
| 412 | + |
| 413 | + $links->button_id = 96; |
289 | 414 | }else{
|
290 | 415 | $links->button_id = $button?->id;
|
291 | 416 | }
|
@@ -353,6 +478,28 @@ public function clickNumber(request $request)
|
353 | 478 | return redirect()->away($link);
|
354 | 479 | }
|
355 | 480 |
|
| 481 | + //Download Vcard |
| 482 | + public function vcard(Request $request) |
| 483 | + { |
| 484 | + $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 | + |
| 489 | + Link::where('id', $linkId)->increment('click_number', 1); |
| 490 | + |
| 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"; |
| 496 | + |
| 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'); |
| 501 | + } |
| 502 | + |
356 | 503 | //Show link, click number, up link in links page
|
357 | 504 | public function showLinks()
|
358 | 505 | {
|
|
0 commit comments