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');
    }
}

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

return (new SmsMessage())
    ->to($notifiable->phone)
    ->from('055-000-0000')
    ->subject('Monthly Newsletter')
    ->content('This is a long message...')
    ->contentType('COMM')
    ->type('LMS');

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');
    }
}

return (new AlimTalkMessage())
    ->templateCode('TEMPLATE001')
    ->to($notifiable->phone)
    ->content('Your order has been shipped.')
    ->addButton(['type' => 'DS', 'name' => 'Track Order'])  // Deep Link
    ->addButton(['type' => 'WL', 'name' => 'Visit Website']);  // Web Link

return (new AlimTalkMessage())
    ->templateCode('TEMPLATE001')
    ->to($notifiable->phone)
    ->content('Reminder: Your appointment is tomorrow.')
    ->setReserved('2026-06-01 09:00', 'Asia/Seoul');

return (new AlimTalkMessage('@custom-plus-friend'))
    ->templateCode('TEMPLATE001')
    ->to($notifiable->phone)
    ->content('Hello!');

// In your .env
LOG_CHANNEL=stack
LOG_LEVEL=debug
bash
php artisan vendor:publish --provider="Seungmun\Sens\SensServiceProvider" --tag="config"
bash
php artisan make:notification SendPurchaseReceipt
bash
# Verify your configuration
php artisan tinker
>>> config('laravel-sens')