承接 ishaarat/lara-ishaarat 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ishaarat/lara-ishaarat

最新稳定版本:1.0.4

Composer 安装命令:

composer require ishaarat/lara-ishaarat

包简介

Send Whatsapp notifications from your laravel application using Ishaarat

README 文档

README

GitHub License Latest Version on Packagist Total Downloads

This is a Laravel Package for Ishaarat Gateway Integration. Now Sending Whatsapp messages is easy.

📦 Install

Via Composer

$ composer require ishaarat/lara-ishaarat

If you are using Laravel 5.5 and higher, the service provider will be automatically registered.

For older versions, you have to add the service provider and alias to your config/app.php:

'providers' => [
    ...
    Ishaarat\LaraIshaarat\Providers\IshaaratServiceProvider::class,
]

'alias' => [
    ...
    'Ishaarat' => Ishaarat\LaraIshaarat\Facades\WA::class,
]

⚡ Configure

Publish the config file

php artisan vendor:publish --provider="Ishaarat\LaraIshaarat\Providers\IshaaratServiceProvider"

Then fill your auth key and app key you got from your Ishaarat Account.

// Eg. for SNS.
'auth_key' => env('ISHAARAT_AUTH_KEY', 'xxxxxx'),
'app_key' => env('ISHAARAT_APP_KEY', 'xxxx'),

or you can add these keys in your .env file

ISHAARAT_AUTH_KEY=xxxxxx
ISHAARAT_APP_KEY=xxxxx

🔥 Usage

By using Facade method.

# On the top of the file.
use Ishaarat\LaraIshaarat\Facades\WA;

////

# In your Controller.
WA::send("this message", function($waMsg) {
    $waMsg->to(['Number 1', 'Number 2']); # The numbers to send to.
});
# OR...
WA::send("this message")->to(['Number 1', 'Number 2'])->dispatch();

By using helper method

ishaaratWA()->send("this message", function($waMsg) {
    $waMsg->to(['Number 1', 'Number 2']); # The numbers to send to.
});

ishaaratWA()->send("this message")->to(['Number 1', 'Number 2'])->dispatch();

😍 Channel Usage

First you have to create your notification using php artisan make:notification command. then WAChannel::class can be used as channel like the below:

namespace App\Notifications;

use Ishaarat\LaraIshaarat\Builder;
use Illuminate\Bus\Queueable;
use Ishaarat\LaraIshaarat\Channels\WAChannel;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;

class InvoicePaid extends Notification
{
    use Queueable;

    /**
     * Get the notification channels.
     *
     * @param  mixed  $notifiable
     * @return array|string
     */
    public function via($notifiable)
    {
        return [WAChannel::class];
    }

    /**
     * Get the repicients and body of the notification.
     *
     * @param  mixed  $notifiable
     * @return Builder
     */
    public function toWhatsapp($notifiable)
    {
        return (new Builder)
            ->send('this message')
            ->to('some number');
    }
}

Tip: You can use the same Builder Instance in the send method.

$builder = (new Builder)
    ->send('this message')
    ->to('some number');

WA::send($builder);

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2023-09-01