Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Sms Office Laravel Package

nikajorjika/laravel-sms-office

Laravel package integrating smsoffice.ge SMS sending. Configure API key, sender, and no-SMS code via .env/config. Send messages via SmsOffice facade or as a Laravel Notification channel, with a log driver available for testing.

View on GitHub
Deep Wiki
Context7

Laravel SMS Office

nikajorjika/laravel-sms-office is a support package for smsoffice.ge.

Installation

Use composer php package manager to install nikajorjika/laravel-sms-office.

composer require nikajorjika/laravel-sms-office

Adding Variables in .env file

# for testing purposes you can also use SMS_OFFICE_DRIVE=log
SMS_OFFICE_DRIVER=sms-office
SMS_OFFICE_KEY=[api-key-provided-by-smsoffice.ge]
SMS_OFFICE_FROM=[sender-name]
SMS_OFFICE_NOSMS=[no-sms-code-provided-by-smsoffice.ge]

To further customize and configure package we first need to publish our config file:

php artisan vendor:publish --provider="Nikajorjika\SmsOffice\SmsOfficeServiceProvider" --tag="config"

this will publish smsoffice.php file inside our config folder:

<?php

return [
    /**
     * Endpoint for sms office url
     */
    'api_url' => env('SMS_OFFICE_URL', 'http://smsoffice.ge/api/v2/send/'),

    /**
     * Private Key provided by sms office service
     */
    'key' => env('SMS_OFFICE_KEY', null),

    /**
     * Driver that serves as a channel driver for laravel
     */
    'driver' => env('SMS_OFFICE_DRIVER', 'sms-office'),

    /**
     * This key defines sender name
     * for the sms to be delivered from
     */
    'from' => env('SMS_OFFICE_FROM', NULL),

    /**
     * List of drivers that sms office package supports
     */
    'supported_drivers' => ['sms-office', 'log'],

    /**
     * Define no sms code for the user to unsubscribe
     */
    'no_sms_code' => env('SMS_OFFICE_NOSMS', NULL),

];

Usage

There are two ways to use this package.

As a Facade

<?php
// Basic Usage
...
use Nikajorjika\SmsOffice\Facades\SmsOffice;

$phoneNumber = '855737812'; // It could also be 995855737812
$message = 'You have found your package ;).';

SmsOffice::message($message)->to($phoneNumber)->send();

As a Channel

To start off, we need to include SmsOfficeChannel::class in via channels array and implement our version of toSms function as shown below.

<?php
...
use Nikajorjika\SmsOffice\SmsOfficeChannel;

class FooBarNotification extends Notification implements ShouldQueue
{
    use Queueable;

    ...

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

    /**
     * Return message to send via SmsOffice Channel
     *
     * @param mixed $notifiable
     * @return string $message
     */
    public function toSms($notifiable)
    {
        return 'You have found your package ;).';
    }

and inside our notifiable model, User in this case, we should implement routeNotificationForSms method, like so:

...
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * Get phone number from notifiable model
     *
     * @return string
     */
    public function routeNotificationForSms()
    {
        return $this->full_phone_number;
    }

that's it now we will be able to send notifications via additional SmsOffice channel.

Package Configuration

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky