PHP code example of corean / laravel-sens

1. Go to this page and download the library: Download corean/laravel-sens 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/ */

    

corean / laravel-sens example snippets


/*
|--------------------------------------------------------------------------
| SMS "From" Number
|--------------------------------------------------------------------------
|
| This configuration option defines the phone number that will be used as
| the "from" number for all outgoing text messages. You should provide
| the number you have already reserved within your Naver Cloud Platform
| /sens/sms-calling-number of dashboard.
|
*/
'sens' => [
    'services' => [
        'sms' => [
            'sender' => env('SENS_SMS_FROM'),
        ],
    ],
],



namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Seungmun\Sens\Sms\SmsChannel;
use Seungmun\Sens\Sms\SmsMessage;
use Illuminate\Notifications\Notification;

class SendPurchaseReceipt extends Notification
{
    use Queueable;

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

    /**
     * Get the sens sms representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return SmsMessage
     */
    public function toSms($notifiable)
    {
        return (new SmsMessage)
            ->to($notifiable->phone)
            ->from('055-000-0000')
            ->content('Welcome: https://open.kakao.com/o/g3dWlf0')
            ->contentType('AD')// You can ignore it (default: COMM)
            ->type('SMS');  // You can ignore it (default: SMS)
    }
}

use App\User;
use App\Notifications\SendPurchaseReceipt;

User::find(1)->notify(new SendPurchaseReceipt);



namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Seungmun\Sens\Sms\SmsChannel;
use Seungmun\Sens\Sms\SmsMessage;
use Illuminate\Http\UploadedFile;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Filesystem\FileNotFoundException;

class SendPurchaseInvoice extends Notification
{
    use Queueable;
    
    /** @var UploadedFile */
    private $image;
    
    /**
     * Create a new notification instance.
     *
     * @param  UploadedFile  $image
     */
    public function __construct(UploadedFile $image)
    {
        $this->image = $image;
    }

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

    /**
     * Get the sens sms representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return SmsMessage
     * @throws FileNotFoundException
     */
    public function toSms($notifiable)
    {
        return (new SmsMessage)
            ->type('MMS')
            ->to($notifiable->phone)
            ->from('055-000-0000')
            ->content('This is your invoice.\nCheck out the attached image.')
            /* file's path string or UploadedFile object of Illuminate are allowed */
            ->file('filename.jpg', $this->image);
    }
}



use App\User;
use App\Notifications\SendPurchaseReceipt;

// In this case, you should only pass UploadedFile object as a parameter.
// If when you need to pass a file path string as a parameter, change your notification class up.
User::find(1)->notify(new SendPurchaseReceipt(request()->file('image')));



namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Seungmun\Sens\AlimTalk\AlimTalkChannel;
use Seungmun\Sens\AlimTalk\AlimTalkMessage;

class SendPurchaseInvoice extends Notification
{
    use Queueable;

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

    /**
     * Get the sens sms representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Seungmun\Sens\AlimTalk\AlimTalkMessage
     */
    public function toAlimTalk($notifiable)
    {
        return (new AlimTalkMessage())
            ->templateCode('TEMPLATE001') // 
bash
php artisan vendor:publish --provider="Seungmun\Sens\SensServiceProvider" --tag="config"
bash
php artisan make:notification SendPurchaseReceipt
bash
php artisan make:notification SendPurchaseInvoice