parsadanashvili/laravel-smsoffice is a Laravel package.
It currently has 0 GitHub stars and 379 downloads on Packagist (latest version v1.1.0).
Install it with composer require parsadanashvili/laravel-smsoffice.
Discover more Laravel packages by parsadanashvili
or browse all Laravel packages to compare alternatives.
Last updated
The Laravel SMSOffice package allows you to easily send SMS messages using the SMSOffice API. It provides a convenient way to integrate SMS functionality into your Laravel applications.
This package is a fork of the original work by lotuashvili/laravel-smsoffice. You can find the original repository here.
You can install the package using Composer:
composer require parsadanashvili/laravel-smsoffice
If you're using Laravel 5.4 or lower, you'll need to manually add the service provider to your config/app.php file. Open the config/app.php file and add the SmsOfficeServiceProvider to the providers array:
// config/app.php
'providers' => [
// Other providers
Parsadanashvili\LaravelSmsOffice\SmsOfficeServiceProvider::class,
],
After adding the service provider, you'll need to publish the configuration:
php artisan vendor:publish --provider="Parsadanashvili\LaravelSmsOffice\SmsOfficeServiceProvider"
You'll need to set up the following environment variables in your .env file:
SMSOFFICE_API_KEY=your_api_key
SMSOFFICE_SENDER=your_default_sender
SMSOFFICE_DRIVER=your_preferred_driver
During development, you can set the SMS driver to log by adding SMSOFFICE_DRIVER=log to your .env file. This will help you simulate SMS sending by logging the actions instead.
User model (or any model you want to send notifications to), add a routeNotificationForSms() method that returns the user's phone number:namespace App\Models;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
// Other code...
public function routeNotificationForSms()
{
return $this->phone; // Adjust this to match your phone number field
}
}
php artisan make:notification SmsNotification
SmsNotification class, import SmsOfficeChannel and add it to the via() method. Define the toSms() method to specify the content of your SMS:use Illuminate\Notifications\Notification;
use Parsadanashvili\LaravelSmsOffice\SmsOfficeChannel;
class SMSNotification extends Notification
{
public function via($notifiable)
{
return [SmsOfficeChannel::class];
}
public function toSms($notifiable)
{
return 'Your Notification Content Here';
}
}
use App\Notifications\SMSNotification;
$user->notify(new SMSNotification());
If you want to send SMS messages without using notifications, you can do so directly:
use Parsadanashvili\LaravelSmsOffice\SmsOffice;
public function sendSms(SmsOffice $smsOffice)
{
$smsOffice->send('599123456', 'Your Message Here');
}
Feel free to replace '599123456' with the recipient's phone number and 'Your Message Here' with the actual message content.
This should help clarify the installation process, configuration, and usage of the Laravel SMSOffice package.