karlos3098/telephone-exchange-play 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

karlos3098/telephone-exchange-play

最新稳定版本:0.0.4

Composer 安装命令:

composer require karlos3098/telephone-exchange-play

包简介

README 文档

README

"Buy Me A Coffee"

To get started, you will need an account on this platform with a purchased phone number.

https://uslugidlafirm.play.pl/welcome/index.html

Installing the package

composer require karlos3098/telephone-exchange-play
php artisan vendor:publish --provider="Karlos3098\TelephoneExchangePlay\PlayProvider" --tag=config

Then in the API Play tab generate Client Id and Client Secret and then put them in the configuration. The last variable is the key validity time. You can choose any time. Just enter the same in .env

TELEPHONE_EXCHANGE_PLAY_DEFAULT_SENDER=48123456789
TELEPHONE_EXCHANGE_PLAY_CLIENT_ID=xxxxxxxxxxxxxxxx
TELEPHONE_EXCHANGE_PLAY_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TELEPHONE_EXCHANGE_PLAY_CLIENT_VALIDITY_TIME=10

Then add the appropriate implementation in the model used for notifications and the method. Here is an example model:

<?php

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

For everything! From now on you can report notifications. Here's an example

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

If your user model returns null or you just want to add more phone numbers you can do it like this:

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

统计信息

  • 总下载量: 52
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-15