09
SepShare links exist on almost every page in every project, creating the code for these share links over and over again can be a pain in the ass. With Laravel Share, you can generate these links in just seconds in a way tailored for Laravel.
Available services
You can install the package via composer:
composer require jorenvanhocht/laravel-share
Publish the package config & resource files.
php artisan vendor:publish --provider="Jorenvh\Share\Providers\ShareServiceProvider"
Fontawesome
Since this package relies on Fontawesome, you will have to require its css, js & fonts in your app. You can do that by requesting an embed code via their website or by installing it locally in your project.
Javascript
Load jquery.min.js & share.js by adding the following lines to your template files.
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs=" crossorigin="anonymous"></script>
<script src="{{ asset('js/share.js') }}"></script>
Creating one share link
Share::page('http://jorenvanhocht.be')->facebook();
Share::page('http://jorenvanhocht.be', 'Your share text can be placed here')->twitter();
Share::page('http://jorenvanhocht.be', 'Your share text can be placed here')->reddit();
Share::page('http://jorenvanhocht.be', 'Share title')->linkedin('Extra linkedin summary can be passed here')
Share::page('http://jorenvanhocht.be')->whatsapp()
Telegram
Share::page('http://jorenvanhocht.be', 'Your share text can be placed here')->telegram();
Sharing the current URL
Instead of manually passing an url, you can opt to use the currentPage
function.
Share::currentPage()->facebook();
Creating multiple share Links
If want multiple share links for (multiple) providers you can just chain the methods like this.
Share::page('http://jorenvanhocht.be', 'Share title')
->facebook()
->twitter()
->linkedin('Extra linkedin summary can be passed here')
->whatsapp();
For more details about this package and source code, Please visit here.
Published at : 09-09-2022
I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.
Launch project