yaro/soc-share

Social network share link builder

1.0.4 2017-03-13 10:43 UTC

This package is auto-updated.

Last update: 2024-10-23 00:47:05 UTC


README

Link builder for social share button for Laravel 5.

Installation

Add dependency to composer.json:

"require": {
    "yaro/soc-share": "1.*"
}

Add to config/app.php:

'providers' => array(
//...
    Yaro\SocShare\ServiceProvider::class,
//...
),
'aliases' => array(
//...
    'SocShare' => Yaro\SocShare\Facade::class,
//...
),

Then run command:

$ php artisan vendor:publish --provider="Yaro\SocShare\ServiceProvider"

Usage

Currently supported networks: google+, facebook, twitter, vkontakte, pinterest, tumblr, odnoklassniki, linkedin.
Ex:

<a href="{{ SocShare::gplus()->getUrl() }}" target="_blank">Google+ ({{ SocShare::gplus()->getCount() }})</a>
<a href="{{ SocShare::pinterest(['media' => asset('/img/pin.png'), 'description' => 'oh hai'])->getUrl() }}" target="_blank">Pin it!</a>

To get share count call getCount() ia your network provider with the same parameters:

<a href="{{ SocShare::pinterest(['media' => asset('/img/pin.png'), 'description' => 'oh hai'])->getUrl() }}" target="_blank">
    Already {{ SocShare::pinterest(['media' => asset('/img/pin.png'), 'description' => 'oh hai'])->getCount() }}
</a>

Or go with js to open share dialog in new window:

{{ SocShare::renderJs() }}

<a onclick="{{ SocShare::vk()->getJs() }}" href="javascript:void(0);">Share me</a>

All parameteres listed in config file.