Skip to content

Commit 5ef1e06

Browse files
committed
v0.0.1
0 parents  commit 5ef1e06

File tree

8 files changed

+224
-0
lines changed

8 files changed

+224
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/vendor
2+
/coverage
3+
composer.phar
4+
composer.lock
5+
.DS_Store
6+
.idea

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 emtiazzahid (Emtiaz Zahid)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# tidio for Laravel
2+
3+
<p>
4+
<a href="https://packagist.org/packages/emtiazzahid/tidio-laravel"><img src="https://img.shields.io/packagist/l/emtiazzahid/tidio-laravel" alt="License"></a>
5+
<a href="https://packagist.org/packages/emtiazzahid/tidio-laravel"><img src="https://img.shields.io/packagist/v/emtiazzahid/tidio-laravel" alt="Latest Version"></a>
6+
<a href="https://packagist.org/packages/emtiazzahid/tidio-laravel"><img src="https://img.shields.io/packagist/dt/emtiazzahid/tidio-laravel" alt="Total Downloads"></a>
7+
</p>
8+
9+
tidio has a lot of [integrations](https://help.tidio.com/docs/integrations), but not for Laravel. This is an tidio chat widget for Laravel.
10+
11+
<p>
12+
<a href="https://www.tidio.com" target="_blank">
13+
<img src="https://user-images.githubusercontent.com/10188029/135708172-13bb6ead-2cff-4b0c-a655-cf015e4efbf3.png" height="461">
14+
</a>
15+
</p>
16+
17+
## Minimum Requirements
18+
19+
- PHP 7.0+
20+
- Laravel 5.5+
21+
22+
## Installation
23+
24+
1. `composer require emtiazzahid/tidio-laravel`
25+
2. `php artisan vendor:publish --provider="EmtiazZahid\Tidio\TidioServiceProvider"`
26+
3. Add your chat link to your `.env` file:
27+
28+
```
29+
USERLIKE_KEY="**84ea169c8b4049a*******ec2f982d58fca8b147184ea6a6d356154036****"
30+
```
31+
####To get your widget key:
32+
- Visit: [your dashboard developer settings](https://www.tidio.com/panel/settings/developer)
33+
- Copy public key
34+
35+
## Usage
36+
37+
Just echo the widget code in your app layout blade inside the body tag:
38+
39+
```html
40+
...
41+
{{ \EmtiazZahid\Tidio\Tidio::widgetCode() }}
42+
</body>
43+
</html>
44+
```
45+
46+
Or, if you don't want to use a config file, you can set your link directly like this:
47+
48+
```html
49+
...
50+
{{ \EmtiazZahid\Tidio\Tidio::widgetCode('your_public_key') }}
51+
</body>
52+
</html>
53+
```
54+
55+
## License
56+
57+
tidio-laravel is released under the MIT license. See [LICENSE](https://github.com/emtiazzahid/tidio-laravel/blob/master/LICENSE) for details.

composer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "emtiazzahid/tidio-laravel",
3+
"description": "A tidio chat widget for Laravel.",
4+
"type": "library",
5+
"keywords": [
6+
"laravel",
7+
"tidio.com",
8+
"tidio",
9+
"tawk",
10+
"chat",
11+
"widget"
12+
],
13+
"license": "MIT",
14+
"homepage": "https://github.com/emtiazzahid/tidio-laravel",
15+
"authors": [
16+
{
17+
"name": "Emtiaz Zahid",
18+
"homepage": "https://github.com/emtiazzahid",
19+
"email": "emtiazzahid@gmail.com"
20+
}
21+
],
22+
"require": {
23+
"php": ">=7.0.0",
24+
"illuminate/support": ">=5.5.0"
25+
},
26+
"autoload": {
27+
"psr-4": {
28+
"EmtiazZahid\\Tidio\\": "src/"
29+
}
30+
},
31+
"extra": {
32+
"laravel": {
33+
"providers": [
34+
"EmtiazZahid\\Tidio\\TidioServiceProvider"
35+
],
36+
"aliases": {
37+
"Tidio": "EmtiazZahid\\Tidio\\Tidio"
38+
}
39+
}
40+
},
41+
"minimum-stability": "dev",
42+
"prefer-stable": true
43+
}

config/tidio.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| tidio widget key
8+
|--------------------------------------------------------------------------
9+
|
10+
| The public key from your admin dashboard at:
11+
| https://www.tidio.com/panel/settings/developer
12+
|
13+
*/
14+
'link' => env('TIDIO_KEY'),
15+
16+
];

src/Tidio.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace EmtiazZahid\Tidio;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class Tidio extends Facade
8+
{
9+
/**
10+
* {@inheritDoc}
11+
*/
12+
protected static function getFacadeAccessor()
13+
{
14+
return \EmtiazZahid\Tidio\TidioAPI::class;
15+
}
16+
}

src/TidioAPI.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace EmtiazZahid\Tidio;
4+
5+
class TidioAPI
6+
{
7+
/**
8+
* Echo out the tidio widget script
9+
*
10+
* @param string|null $link
11+
* @return void
12+
* @throws \Exception
13+
*/
14+
public function widgetCode(string $link = null)
15+
{
16+
$link = $link ?? config('tidio.link');
17+
18+
if (empty($link)) {
19+
throw new \Exception('Your tidio public key can not be empty.');
20+
}
21+
22+
echo self::script($link);
23+
}
24+
25+
/**
26+
* Create Tidio JavaScript code.
27+
*
28+
* @param string $key
29+
* @return string
30+
*/
31+
private static function script(string $key) : string
32+
{
33+
$embed_link = 'https://code.tidio.co/' . $key . '.js';
34+
35+
return '<script type="text/javascript" src="'.$embed_link.'" async></script>';
36+
}
37+
}

src/TidioServiceProvider.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace EmtiazZahid\Tidio;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class TidioServiceProvider extends ServiceProvider
8+
{
9+
/**
10+
* Bootstrap any application services.
11+
*
12+
* @return void
13+
*/
14+
public function boot()
15+
{
16+
$this->publishes([
17+
__DIR__.'/../config/tidio.php' => config_path('tidio.php'),
18+
], 'config');
19+
}
20+
21+
/**
22+
* {@inheritDoc}
23+
*/
24+
public function register()
25+
{
26+
//
27+
}
28+
}

0 commit comments

Comments
 (0)