PHP code example of ghasedaksms / ghasedaksms-laravel

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

    

ghasedaksms / ghasedaksms-laravel example snippets


GHASEDAK_SMS_API_KEY="b7ee4eace78************************************************"



namespace App\Notifications;

use Carbon\Carbon;
use Ghasedak\DataTransferObjects\Request\InputDTO;
use Ghasedak\DataTransferObjects\Request\ReceptorDTO;
use Ghasedaksms\GhasedaksmsLaravel\Message\GhasedaksmsVerifyLookUp;
use Ghasedaksms\GhasedaksmsLaravel\Notification\GhasedaksmsBaseNotification;
use Illuminate\Bus\Queueable;

class SendOtpToUser extends GhasedaksmsBaseNotification
{
    use Queueable;

    public function __construct()
    {
        //
    }

    public function toGhasedaksms($notifiable): GhasedaksmsVerifyLookUp
    {
        $message = new GhasedaksmsVerifyLookUp();
        $message->setSendDate(Carbon::now());
        $message->setReceptors([new ReceptorDTO($notifiable->mobile, 'client referenceId')]);
        $message->setTemplateName('newOTP');
        $message->setInputs([new InputDTO('code', '******')]);
        return $message;
    }
}

$user = new \App\Models\User();
$user->mobile = '0912*******';
$user->notify(new \App\Notifications\SendOtpToUser());

php artisan make:notification SendOtpToUser