mirror of
https://github.com/alexjustesen/speedtest-tracker.git
synced 2026-06-23 07:00:08 +00:00
61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Helpers\Number;
|
|
use App\Models\Result;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Str;
|
|
|
|
class CompletedSpeedtestMail extends Mailable implements ShouldQueue
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
/**
|
|
* Create a new message instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(
|
|
public Result $result,
|
|
) {}
|
|
|
|
/**
|
|
* Get the message envelope.
|
|
*/
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(
|
|
subject: 'Speedtest Completed - #'.$this->result->id,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the message content definition.
|
|
*/
|
|
public function content(): Content
|
|
{
|
|
return new Content(
|
|
markdown: 'mail.speedtest.completed',
|
|
with: [
|
|
'id' => $this->result->id,
|
|
'service' => Str::title($this->result->service->getLabel()),
|
|
'serverName' => $this->result->server_name,
|
|
'serverId' => $this->result->server_id,
|
|
'isp' => $this->result->isp,
|
|
'ping' => round($this->result->ping, 2).' ms',
|
|
'download' => Number::toBitRate(bits: $this->result->download_bits, precision: 2),
|
|
'upload' => Number::toBitRate(bits: $this->result->upload_bits, precision: 2),
|
|
'packetLoss' => $this->result->packet_loss ? round($this->result->packet_loss, precision: 2) : '',
|
|
'speedtest_url' => $this->result->result_url,
|
|
'url' => url('/admin/results'),
|
|
],
|
|
);
|
|
}
|
|
}
|