1. Go to this page and download the library: Download rolfhaug/laravel-front-sms 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/ */
rolfhaug / laravel-front-sms example snippets
php artisan make:sms WelcomeMessage
namespace App\Notifications\Sms;
use RolfHaug\FrontSms\Notifications\SmsNotification;
class WelcomeMessage extends SmsNotification
{
public $message = 'Hi %s, today was a good day!';
public function getMessage($notifiable)
{
return vsprintf($this->message, [
$notifiable->name,
]);
}
}
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use RolfHaug\FrontSms\Traits\Smsable;
class User extends Authenticatable
{
use Notifiable, Smsable;
// ...
}
namespace App\Notifications\Sms;
use RolfHaug\FrontSms\Notifications\SmsNotification;
class WelcomeMessage extends SmsNotification
{
public $message = 'Hi %s, today was a good day!';
public function getMessage($notifiable)
{
return vsprintf($this->message, [
$notifiable->name,
]);
}
}
$message = new SmsNotification('This is my text message.');
// Send it to a user
$user = App\User::first();
$user->notify($message);
namespace App\Notifications\Sms;
use RolfHaug\FrontSms\Notifications\SmsNotification;
use App\Order;
class OrderConfirmation extends SmsNotification
{
private $order;
public function __construct($message = null, Order $order)
{
$this->order = $order;
parent::__construct($message);
}
public $message = 'Hi %s, thank you for your order! You can download your receipt here %s';
public function getMessage($notifiable)
{
return vsprintf($this->message, [
$notifiable->name,
$this->order->receiptLink()
]);
}
}