<?php

namespace App\Notifications\Netmails;

use Illuminate\Support\Facades\Log;

use App\Notifications\Netmails;
use App\Models\{Netmail,System};
use App\Traits\PageTemplate;

class Test extends Netmails
{
	use PageTemplate;

	private const LOGKEY = 'NNT';

	/**
	 * Get the mail representation of the notification.
	 *
	 * @param mixed $notifiable
	 * @return Netmail
	 * @throws \Exception
	 */
	public function toNetmail(object $notifiable): Netmail
	{
		$o = $this->setupNetmail($notifiable);
		$ao = $notifiable->routeNotificationFor(static::via);

		Log::info(sprintf('%s:+ Creating TEST netmail to [%s]',self::LOGKEY,$ao->ftn));

		$o->subject = 'Testing 1, 2, 3...';

		// Message
		$msg = $this->page(TRUE,'Test');

		$msg->addText(
			"Hi there,\r\r".
			"This is just a test netmail to make sure we can send a message to your system.\r\r".
			"There is no need to reply, but if you do, it'll boost my spirits :)\r"
		);

		$o->msg = $msg->render();
		$o->tagline = 'Testing, testing, 1 2 3.';

		$o->save();

		return $o;
	}
}