LaravelPackages.net
Acme Inc.
Toggle sidebar
michelmelo/laravel-share

Optional package for Laravel to generate social share links.

2
0
About michelmelo/laravel-share

michelmelo/laravel-share is a Laravel package for optional package for laravel to generate social share links.. It currently has 0 GitHub stars and 2 downloads on Packagist. Install it with composer require michelmelo/laravel-share. Discover more Laravel packages by michelmelo or browse all Laravel packages to compare alternatives.

Last updated

Laravel Share

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.

Available services

  • Facebook
  • Twitter
  • Linkedin
  • WhatsApp
  • Reddit
  • Telegram

Installation

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.

Fontawesome

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.

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"></script>
<script src="{{ asset('js/share.js') }}"></script>

Usage

Facebook

Share::page('http://michelmelo.pt')->facebook();

Twitter

Share::page('http://michelmelo.pt', 'Your share text can be placed here')->twitter();

Reddit

Share::page('http://michelmelo.pt', 'Your share text can be placed here')->reddit();

Linkedin

Share::page('http://michelmelo.pt', 'Share title')->linkedin('Extra linkedin summary can be passed here')

Whatsapp

Share::page('http://michelmelo.pt')->whatsapp()

Telegram

Share::page('http://michelmelo.pt', '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();

Star History Chart