Skip to content

Commit

Permalink
v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
emtiazzahid committed Oct 1, 2021
0 parents commit 1184177
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/vendor
/coverage
composer.phar
composer.lock
.DS_Store
.idea
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 emtiazzahid (Emtiaz Zahid)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# userlike.com for Laravel

<p>
<a href="https://packagist.org/packages/emtiazzahid/userlike-laravel"><img src="https://img.shields.io/packagist/l/emtiazzahid/userlike-laravel" alt="License"></a>
<a href="https://packagist.org/packages/emtiazzahid/userlike-laravel"><img src="https://img.shields.io/packagist/v/emtiazzahid/userlike-laravel" alt="Latest Version"></a>
<a href="https://packagist.org/packages/emtiazzahid/userlike-laravel"><img src="https://img.shields.io/packagist/dt/emtiazzahid/userlike-laravel" alt="Total Downloads"></a>
</p>

userlike.com has a lot of [integrations](https://www.userlike.com/en/addons), but not for Laravel. This is an userlike chat widget for Laravel.

<p>
<a href="https://www.userlike.com" target="_blank">
<img src="https://user-images.githubusercontent.com/10188029/135655361-2185e15b-5944-44bf-8cd6-ecfbd13596a8.png" height="461">
</a>
</p>

## Minimum Requirements

- PHP 7.0+
- Laravel 5.5+

## Installation

1. `composer require emtiazzahid/userlike-laravel`
2. `php artisan vendor:publish --provider="EmtiazZahid\UserLike\UserLikeServiceProvider"`
3. Add your chat link to your `.env` file:

```
USERLIKE_KEY="**84ea169c8b4049a*******ec2f982d58fca8b147184ea6a6d356154036****"
```
####To get your widget key:
- Visit: [your dashboard](https://www.userlike.com/en/dashboard/um/config/um_widget/overview)
- Select your website
- Select **Install** from right side
- Select **Credentials for Applications**

## Usage

Just echo the widget code in your app layout blade inside the body tag:

```html
...
{{ \EmtiazZahid\UserLike\UserLike::widgetCode() }}
</body>
</html>
```

Or, if you don't want to use a config file, you can set your link directly like this:

```html
...
{{ \EmtiazZahid\UserLike\UserLike::widgetCode('your_widget_key') }}
</body>
</html>
```

## License

userlike-laravel is released under the MIT license. See [LICENSE](https://github.com/emtiazzahid/userlike-laravel/blob/master/LICENSE) for details.
43 changes: 43 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "emtiazzahid/userlike-laravel",
"description": "A userlike chat widget for Laravel.",
"type": "library",
"keywords": [
"laravel",
"userlike.com",
"userlike",
"tawk",
"chat",
"widget"
],
"license": "MIT",
"homepage": "https://github.com/emtiazzahid/userlike-laravel",
"authors": [
{
"name": "Emtiaz Zahid",
"homepage": "https://github.com/emtiazzahid",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.0.0",
"illuminate/support": ">=5.5.0"
},
"autoload": {
"psr-4": {
"EmtiazZahid\\UserLike\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"EmtiazZahid\\UserLike\\UserLikeServiceProvider"
],
"aliases": {
"UserLike": "EmtiazZahid\\UserLike\\UserLike"
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
16 changes: 16 additions & 0 deletions config/userlike.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| userlike widget key
|--------------------------------------------------------------------------
|
| The widget key from your admin dashboard at:
| https://www.userlike.com/en/dashboard/um/config/um_widget/overview
|
*/
'link' => env('USERLIKE_KEY'),

];
16 changes: 16 additions & 0 deletions src/UserLike.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace EmtiazZahid\UserLike;

use Illuminate\Support\Facades\Facade;

class UserLike extends Facade
{
/**
* {@inheritDoc}
*/
protected static function getFacadeAccessor()
{
return \EmtiazZahid\UserLike\UserLikeAPI::class;
}
}
37 changes: 37 additions & 0 deletions src/UserLikeAPI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace EmtiazZahid\UserLike;

class UserLikeAPI
{
/**
* Echo out the userlike widget script
*
* @param string|null $link
* @return void
* @throws \Exception
*/
public function widgetCode(string $link = null)
{
$link = $link ?? config('userlike.link');

if (empty($link)) {
throw new \Exception('Your userlike widget key can not be empty.');
}

echo self::script($link);
}

/**
* Create UserLike JavaScript code.
*
* @param string $key
* @return string
*/
private static function script(string $key) : string
{
$embed_link = 'https://userlike-cdn-widgets.s3-eu-west-1.amazonaws.com/' . $key . '.js';

return '<script async type="text/javascript" src="'.$embed_link.'"></script>';
}
}
28 changes: 28 additions & 0 deletions src/UserLikeServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace EmtiazZahid\UserLike;

use Illuminate\Support\ServiceProvider;

class UserLikeServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->publishes([
__DIR__.'/../config/userlike.php' => config_path('userlike.php'),
], 'config');
}

/**
* {@inheritDoc}
*/
public function register()
{
//
}
}

0 comments on commit 1184177

Please sign in to comment.