Downloads
Stars
Version
Share 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.
You can install the package via composer:
composer require michelmelo/laravel-share
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
// config/app.php
'providers' => [
MichelMelo\Share\Providers\ShareServiceProvider::class,
];
And optionally add the facade in config/app.php
// config/app.php
'aliases' => [
'Share' => MichelMelo\Share\ShareFacade::class,
];
Publish the package config & resource files.
php artisan vendor:publish --provider="MichelMelo\Share\Providers\ShareServiceProvider"
You might need to republish the config file when updating to a newer version of Laravel Share
This will publish the laravel-share.php
config file to your config folder, share.js
in public/js/
and laravel-share.php
in your resources/lang/vendor/en/
folder.
Since this package relies on Fontawesome, you will have to require it's css, js & fonts in your app. You can do that by requesting a embed code via their website or by installing it locally in your project.
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"></script>
<script src="{{ asset('js/share.js') }}"></script>
Share::page('http://michelmelo.pt')->facebook();
Share::page('http://michelmelo.pt', 'Your share text can be placed here')->twitter();
Share::page('http://michelmelo.pt', 'Your share text can be placed here')->reddit();
Share::page('http://michelmelo.pt', 'Share title')->linkedin('Extra linkedin summary can be passed here')
Share::page('http://michelmelo.pt')->whatsapp()
Share::page('http://michelmelo.pt', 'Your share text can be placed here')->telegram();
Instead of manually passing an url, you can opt to use the currentPage
function.
Share::currentPage()->facebook();