Cherry-Pie / SocShare by Cherry Pie

Social network share link builder
1,848
9
2
Package Data
Maintainer Username: Cherry Pie
Maintainer Contact: 12fcv4@gmail.com (Yaro)
Package Create Date: 2015-02-09
Package Last Update: 2017-03-13
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-12-19 03:24:31
Package Statistics
Total Downloads: 1,848
Monthly Downloads: 1
Daily Downloads: 0
Total Stars: 9
Total Watchers: 2
Total Forks: 2
Total Open Issues: 0

SocShare

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.