Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Lotuashvili/laravel-smsoffice
📲 SmsOffice.ge service with notification channel for Laravel
https://github.com/Lotuashvili/laravel-smsoffice
Last synced: about 2 months ago
JSON representation
📲 SmsOffice.ge service with notification channel for Laravel
- Host: GitHub
- URL: https://github.com/Lotuashvili/laravel-smsoffice
- Owner: Lotuashvili
- Created: 2018-11-20T10:15:15.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-24T19:14:05.000Z (about 2 years ago)
- Last Synced: 2024-10-04T09:14:59.819Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 56.6 KB
- Stars: 15
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-georgia - Lotuashvili/laravel-smsoffice - Laravel package for smsoffice.ge service, supports laravel notifications. (Categories)
README
# Laravel SmsOffice
[![Latest Stable Version](https://img.shields.io/packagist/v/lotuashvili/laravel-smsoffice.svg)](https://packagist.org/packages/lotuashvili/laravel-smsoffice)
[![Total Downloads](https://img.shields.io/packagist/dt/lotuashvili/laravel-smsoffice.svg)](https://packagist.org/packages/lotuashvili/laravel-smsoffice)
[![Downloads Month](https://img.shields.io/packagist/dm/lotuashvili/laravel-smsoffice.svg)](https://packagist.org/packages/lotuashvili/laravel-smsoffice)This package allows you to send SMS messages with SmsOffice.ge API
You can send sms with notification class or directly with SmsOffice class
![Laravel SmsOffice](cover.png)
## Table of Contents
- [Installation](#installation)
- [Development Mode Config](#development-mode-config)
- [Usage](#usage)## Installation
```
composer require lotuashvili/laravel-smsoffice
```#### For Laravel <= 5.4
If you're using Laravel 5.4 or lower, you have to manually add a service provider in your `config/app.php` file.
Open `config/app.php` and add `SmsOfficeServiceProvider` to the `providers` array.```php
'providers' => [
# Other providers
Lotuashvili\LaravelSmsOffice\SmsOfficeServiceProvider::class,
],
```Then run:
```
php artisan vendor:publish --provider="Lotuashvili\LaravelSmsOffice\SmsOfficeServiceProvider"
```Place your api key and sender name in `config/smsoffice.php` file
## Development mode config
If you want to use log in development instead of sending real sms, then add `SMSOFFICE_DRIVER=log` to your `.env` file
## Usage
### Send with notification class
In `User` class, add `routeNotificationForSms()` method and return phone number of user
```php
class User extends Authenticatable
{
# Code...public function routeNotificationForSms()
{
return $this->phone;
}
}
```Create notification
```
php artisan make:notification FooNotification
```In our newly created notification, import `SmsOfficeChannel` and add it to `via()` method. Write notification content in `toSms()` method
```php
use Illuminate\Notifications\Notification;
use Lotuashvili\LaravelSmsOffice\SmsOfficeChannel;class FooNotification extends Notification
{
public function via($notifiable)
{
return [SmsOfficeChannel::class];
}
public function toSms($notifiable)
{
return 'Test Notification';
}
}
```And then send notification to user
```php
$user->notify(new FooNotification)
```### Send directly without notification
You have to inject or initialize `SmsOffice` class and then call `send` function
```php
use Lotuashvili\LaravelSmsOffice\SmsOffice;public function sendSms(SmsOffice $smsoffice)
{
$smsoffice->send('599123123', 'Test Message');
}
```### Get Balance
```php
use Lotuashvili\LaravelSmsOffice\SmsOffice;public function getBalance(SmsOffice $smsoffice)
{
$smsoffice->balance();
}
```