Laravel Share
View Package
Laravel Share simplifies the process of sharing URLs across multiple social media platforms within Laravel applications. With straightforward integration steps and support for various platforms, developers can enhance user engagement by enabling sharing functionalities.
Installation:
Install the package via Composer:
composer require dipesh79/laravel-share
Usage:
- Compact the Required Social Media Share Link to Blade:
<?php use Dipesh79\LaravelShare\LaravelShare; // Your Controller Method public function index() { $share = new LaravelShare(); $facebook_link = $share->facebook(); // Share the current URL // OR $facebook_link = $share->facebook("custom_url"); // Share the given URL // Compact the share link to your blade return view('index', compact('facebook_link')); }
- Add the URL to Href Tag in Blade:
<a href="{{$facebook_link}}" target="_blank">Share To Facebook</a>
Alternatively, if you need to use it in multiple blade files, use it in AppServiceProvider:
<?php use Dipesh79\LaravelShare\LaravelShare; use Illuminate\Support\Facades\View; public function boot() { $share = new LaravelShare(); View::share('share', $share); }
Then, you can use the share variable in any blade file in the Laravel project. Simply use {{$share->facebook()}} to add the respective social media share link in any blade file.
Currently Available Platforms:
- Telegram
- Tumblr
- Viber
- Gmail
- Trello
- Facebook Messenger
- Skype
- Tencent QQ
License: MIT
Author: @Dipesh79
Support: For support, email [email protected].
This post is licensed under CC BY
4.0 by the
author.