PHP code example of parsadanashvili / laravel-smsoffice
1. Go to this page and download the library: Download parsadanashvili/laravel-smsoffice library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
parsadanashvili / laravel-smsoffice example snippets
// config/app.php
'providers' => [
# Other providers
Parsadanashvili\LaravelSmsOffice\SmsOfficeServiceProvider::class,
],
namespace App\Models;
class User extends Authenticatable
{
// Other Code...
public function routeNotificationForSms()
{
return $this->phone;
}
}
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 Parsadanashvili\LaravelSmsOffice\SmsOffice;
public function sms(SmsOffice $smsOffice)
{
$smsOffice->send('599123456', 'Your Message Here');
}
// config/app.php
'providers' => [
// Other providers
Parsadanashvili\LaravelSmsOffice\SmsOfficeServiceProvider::class,
],
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
}
}
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());
use Parsadanashvili\LaravelSmsOffice\SmsOffice;
public function sendSms(SmsOffice $smsOffice)
{
$smsOffice->send('599123456', 'Your Message Here');
}