PHP code example of karlos3098 / telephone-exchange-play

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

    

karlos3098 / telephone-exchange-play example snippets


composer 

php artisan vendor:publish --provider="Karlos3098\TelephoneExchangePlay\PlayProvider" --tag=config



namespace Karlos3098\TelephoneExchangePlay\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Notifications\Notification;
use Karlos3098\TelephoneExchangePlay\Interfaces\HasDifferentPhoneNumberForTelephoneExchangePlay;

class TestClient extends Authenticatable implements HasDifferentPhoneNumberForTelephoneExchangePlay
{
    /** @use HasFactory<\Database\Factories\UserFactory> */
    use HasFactory, Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var list<string>
     */
    protected $fillable = [
        'name',
        'email',
        'password',
        'phone_number',
    ];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var list<string>
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * Get the attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'email_verified_at' => 'datetime',
            'password' => 'hashed',
        ];
    }

    public function routeNotificationForTelephoneExchangePlay(Notification $notification): array|string|null
    {
        return $this->phone_number;
    }
}


use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Karlos3098\TelephoneExchangePlay\Interfaces\TelephoneExchangePlayNotification;
use Karlos3098\TelephoneExchangePlay\Services\PlayMessage;

class TestNotification extends Notification implements TelephoneExchangePlayNotification
{
    use Queueable;

    /**
     * Create a new notification instance.
     */
    public function __construct()
    {
    }

    /**
     * Get the notification's delivery channels.
     *
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return [
            'play-exchange',
        ];
    }

    /**
     * Get the mail representation of the notification.
     */
    public function toMail(object $notifiable): MailMessage
    {
        return (new MailMessage)
                    ->line('The introduction to the notification.')
                    ->action('Notification Action', url('/'))
                    ->line('Thank you for using our application!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return [
            //
        ];
    }

    public function toPlayTelephoneExchange($notifiable): PlayMessage
    {
        return (new PlayMessage)
            ->line("example")
            ->line("message");
    }
}


public function toPlayTelephoneExchange($notifiable): PlayMessage
    {
        return (new PlayMessage)
            ->phoneNumber("48123456789", "48987654321", ...)
            ->line("example")
            ->line("message");
    }