system 1 -------------------------------------------------------------- https://packagist.org/packages/jeroendesloovere/vcard https://www.youtube.com/watch?v=P00L1fFar7E&t=153s https://www.youtube.com/watch?v=P00L1fFar7E composer require jeroendesloovere/vcard Route::get('/test', [WelcomeController::class, 'test']); use JeroenDesloovere\VCard\VCard; public function test(Request $request){ // define vcard $vcard = new VCard(); // define variables $lastname = 'Desloovere'; $firstname = 'Jeroen'; $additional = ''; $prefix = ''; $suffix = ''; // add personal data $vcard->addName($lastname, $firstname, $additional, $prefix, $suffix); // add work data $vcard->addCompany('Siesqo'); $vcard->addJobtitle('Web Developer'); $vcard->addRole('Data Protection Officer'); $vcard->addEmail('info@jeroendesloovere.be'); $vcard->addPhoneNumber(1234121212, 'PREF;WORK'); $vcard->addPhoneNumber(123456789, 'WORK'); $vcard->addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium'); $vcard->addLabel('street, worktown, workpostcode Belgium'); $vcard->addURL('http://www.jeroendesloovere.be'); $vcard->addPhoto(public_path'abc.jpeg'); // return vcard as a string return $vcard->getOutput(); // return vcard as a download //return $vcard->download(); } public function vcf($id){ $user = User::find($id); $vcard = new VCard(); $lastname = ''; $firstname = $user["name"]; $additional = ''; $prefix = ''; $suffix = ''; $vcard->addName($lastname, $firstname, $additional, $prefix, $suffix); // $vcard->addCompany(''); // $vcard->addRole(''); // $vcard->addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium'); // $vcard->addLabel('street, worktown, workpostcode Belgium'); $vcard->addJobtitle($user["designation"]); $vcard->addEmail($user["email"]); $vcard->addPhoneNumber($user["number"], 'PREF;WORK'); $vcard->addPhoneNumber($user["whatsapp"], 'WhatsApp'); $vcard->addURL($user["facebook"]); $vcard->addPhoto(public_path('images/users/' . $user["image"])); $content = $vcard->download(); return response($content, 200, [ 'Content-Type' => 'text/x-vcard', 'Content-Disposition' => 'attachment; filename="contact.vcf"' ]); } system 2 [working] -------------------------------------------------------------- https://www.youtube.com/watch?v=1th42YyQKiI&list=LL&index=1 composer require jeroendesloovere/vcard:dev-2.0.0-dev Route::get('/save/vcf/{id}', [WelcomeController::class, 'vcf']); use App\Models\User; use JeroenDesloovere\VCard\VCard; use JeroenDesloovere\VCard\Property\Name; use JeroenDesloovere\VCard\Formatter\VcfFormatter; use JeroenDesloovere\VCard\Property\Telephone; use JeroenDesloovere\VCard\Property\Email; use JeroenDesloovere\VCard\Formatter\Formatter; public function vcf($id){ $vcard = null; $formatter = new Formatter(new VcfFormatter(), 'vcard-export'); $user = User::find($id); $lastname = ""; $firstname = $user["name"]; $additional = ""; $prefix = ""; $suffix = ""; $number = $user->number; $email = $user->email; $vcard = new VCard(); $vcard->add(new Telephone($number)); $vcard->add(new Name($lastname, $firstname, $additional, $prefix, $suffix)); $vcard->add(new Email($email)); $formatter->addVCard($vcard); $content = $formatter->download(); return response($content, 200, [ 'Content-Type' => 'text/x-vcard', 'Content-Disposition' => 'attachment; filename="contact.vcf"' ]); } ------------------------------------- use JeroenDesloovere\VCard\VCard; use JeroenDesloovere\VCard\Property\Name; use JeroenDesloovere\VCard\Formatter\VcfFormatter; use JeroenDesloovere\VCard\Property\Telephone; use JeroenDesloovere\VCard\Formatter\Formatter; public function vcf(){ $vcard = null; $formatter = new Formatter(new VcfFormatter(), 'vcard-export'); $users = User::get(); foreach($users as $user) { $lastname = ""; $firstname = $user["name"]; $additional = ""; $prefix = "Eng."; $suffix = ""; $vcard = new VCard(); $vcard->add(new Telephone($user["number"])); $vcard->add(new Name($lastname, $firstname, $additional, $prefix, $suffix)); $formatter->addVCard($vcard); } $formatter->download(); return 'exported'; } system 3 -------------------------------------------------------------- https://github.com/Astrotomic/laravel-vcard composer require astrotomic/laravel-vcard use Astrotomic\Vcard\Properties\Email; use Astrotomic\Vcard\Properties\Gender; use Astrotomic\Vcard\Properties\Kind; use Astrotomic\Vcard\Properties\Tel; use Astrotomic\Vcard\Vcard; use Carbon\Carbon; Vcard::make() ->kind(Kind::INDIVIDUAL) ->gender(Gender::MALE) ->fullName('John Adam Smith') ->name('Smith', 'John', 'Adam') ->email('john.smith@mail.com') ->email('john.smith@company.com', [Email::WORK, Email::INTERNET]) ->tel('+1234567890', [Tel::HOME, Tel::VOICE]) ->tel('+0987654321', [Tel::WORK, Tel::VOICE]) ->tel('+0123456789', [Tel::CELL, Tel::VOICE]) ->url('https://johnsmith.com') ->url('https://company.com') ->bday(Carbon::parse('1990-06-24')) ->adr('','','1600 Pennsylvania Ave NW', 'Washington', 'DC', '20500-0003', 'USA') ->photo('data:image/jpeg;base64,'.base64_encode(file_get_contents(__DIR__.'/stubs/photo.jpg'))) ->title('V. P. Research and Development') ->role('Excecutive') ->org('Google', 'GMail Team', 'Spam Detection Squad') ->member('john.smith@company.com', '550e8400-e29b-11d4-a716-446655440000') ->note('Hello world') ; system 4 [row] -------------------------------------------------------------- https://www.youtube.com/watch?v=x1guN0iBKPI