moeen-basra/send-pk

Send SMS via SendPk

v1.1.0 2022-09-01 17:11 UTC

This package is auto-updated.

Last update: 2024-10-29 06:25:39 UTC


README

The package for laravel to send sms messages using the send pk

Site Url

Prerequisites

  1. php >= 8.1
  2. guzzlehttp/guzzle >= 7

Installation

composer require moeen-basra/send-pk

Publish config

php artisan vendor:publish --tag send-pk-config

Publish lang if you want localization

php artisan vendor:publish --tag send-pk-lang

How to use

Before moving forward make sure you update the config/send-pk.php file.

Using the SmsMessage

<?php

use MoeenBasra\SendPk\SmsMessage

class MyClass {
    public function sendMessage(): void
    {
        $response = (new SmsMessage())
            ->fields('template_id', confg('send-pk.templates.{my_template_id}'))
            ->fields('message', [
                // template parameters
            ]);

        if ($response->code === 200) {
            // handle success
        } else {
            // handle failed
        }
    }
}

Using the container

<?php

class MyClass {
    public function sendMessage(): void
    {
        $response = app('send-pk')
            ->send($phone_number, [
                'template_id' => confg('send-pk.templates.{my_template_id}'),
                'message' => [
                    // template parameters
                ]
            ]);
        if ($response->code === 200) {
            // handle success
        } else {
            // handle failed
        }
    }
}

Contact

Reach me at email here