Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 5
MmsChannel
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 5
 send
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 5
1<?php
2
3namespace AGILEDROP\LaravelTelnyx\Channels;
4
5use Illuminate\Notifications\Notification;
6use Telnyx\Message;
7use Telnyx\Telnyx;
8
9class MmsChannel extends BaseChannel
10{
11    /**
12     * Send the given notification trough MMS
13     *
14     * @param  mixed  $notifiable
15     * @param  \Illuminate\Notifications\Notification  $notification
16     *
17     * @return \Telnyx\ApiResource|void
18     */
19    public function send($notifiable, Notification $notification)
20    {
21        // routeNotificationFor()  has to be overridden in the user model of the app
22        if (! $to = $notifiable->routeNotificationFor('telnyx', $notification)) {
23            return;
24        }
25
26        // toTelnyx() has to be implemented in the notification
27        $message = $notification->toTelnyx($notifiable);
28
29        Telnyx::setApiKey(config('laravel-telnyx.api_key'));
30
31        return Message::Create([
32            "messaging_profile_id" => $this->profileId,
33            'from' => $message->from ?: $this->from,
34            'to' => $to,
35            'text' => trim($message->content),
36            'subject' => $message->subject,
37            'media_urls' => $message->images,
38        ]);
39    }
40}