Git Product home page Git Product logo

karix-sms's Introduction

Karix Sms and Whatsapp notifications channel for Laravel 6

This package makes it easy to send sms via Karix.io with Laravel 6 or up.

Installation

You can install the package via composer:

composer require samuelbie/karix

Setting up the Karix id and token

Login to Karix.io and get your ID and Token, put that on your .env file and add your Karix Id and Token to your config/services.php:

// config/karix.php
<?php
    return [
        'id'            => env('KARIX_ID'),
        'token'         => env('KARIX_TOKEN'),
        'sms_from'      => env('KARIX_FROM'),
        'whatsapp_from' => env('KARIX_WHATSAPP')
    ];

Usage

Now you can use the channel in your via() method inside the notification:

use Samuelbie\Karix\Broadcasting\KarixMessage;
use Samuelbie\Karix\Broadcasting\KarixSMSChannel;
use Samuelbie\Karix\Broadcasting\KarixWhatsappChannel;


class YourNotification extends Notification
{
    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [KarixSMSChannel::class, KarixWhatsappChannel::class];
    }


    public function toSmSKarix($notifiable)
    {
        return KarixMessage::create()
            ->content(['text' => 'Your message comes here']);
    }

    public function toWhatsappKarix($notifiable)
    {
        return KarixMessage::create()
            ->content([
                'text' => 'Your message comes here',
                'media' => 'url-to-media',
                'location' => [
                    'latitude' => 'the latitude here',
                    'longitude' => 'the longitude here'
                ]
            ]);
    }
}

In order to let your Notification know that there is a new channel called KarixSmsChannel, add the routeNotificationForKarix method to your Notifiable model (probably your user.php file).

This method needs to return email of the user (if it's a private board) and the list ID of the Trello list to add the card to.

Caveat : Make sure you have a 'phone' field in your table along with country code like +91xxxxxxxxxx for which you are using this.

public function routeNotificationForKarix()
{
    return $this->phone;
}

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

karix-sms's People

Contributors

samuel-bie avatar

Stargazers

Pratik Rane avatar

Watchers

James Cloos avatar  avatar

Forkers

pratik149

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.