PHP code example of cable8mm / laravel-sens

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

    

cable8mm / laravel-sens example snippets




namespace App\Notifications;

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

class SendPurchaseReceipt extends Notification
{
    use Queueable;

    public function via($notifiable): array
    {
        return [SmsChannel::class];
    }

    public function toSms($notifiable): SmsMessage
    {
        return (new SmsMessage())
            ->to($notifiable->phone)
            ->from('055-000-0000')
            ->content('Your purchase receipt is ready.')
            ->contentType('COMM')
            ->type('SMS');
    }
}

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

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



namespace App\Notifications;

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

class SendPurchaseInvoice extends Notification
{
    use Queueable;

    public function __construct(private UploadedFile $image)
    {
    }

    public function via($notifiable): array
    {
        return [SmsChannel::class];
    }

    /**
     * @throws FileNotFoundException
     */
    public function toSms($notifiable): SmsMessage
    {
        return (new SmsMessage())
            ->type('MMS')
            ->to($notifiable->phone)
            ->from('055-000-0000')
            ->content("This is your invoice.\nCheck out the attached image.")
            ->file('invoice.jpg', $this->image);
    }
}

use App\Models\User;
use App\Notifications\SendPurchaseInvoice;

User::find(1)->notify(new SendPurchaseInvoice(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 SendShippingNotice extends Notification
{
    use Queueable;

    public function via($notifiable): array
    {
        return [AlimTalkChannel::class];
    }

    public function toAlimTalk($notifiable): AlimTalkMessage
    {
        return (new AlimTalkMessage())
            ->templateCode('TEMPLATE001')
            ->to($notifiable->phone)
            ->content('Your order has been shipped.')
            ->countryCode('82')
            ->addButton(['type' => 'DS', 'name' => 'Tracking of Shipment'])
            ->setReserved('2026-05-31 14:20', 'Asia/Seoul');
    }
}
bash
php artisan vendor:publish --provider="Seungmun\Sens\SensServiceProvider" --tag="config"
bash
php artisan make:notification SendPurchaseReceipt