Right now I have a route that does this:
use \Illuminate\Mail\Markdown;
use App\Models\User;
use App\Models\License;
use App\Notifications\ContentLicense;
Route::get('/mailable/content-license', function() {
$license = License::with(['content', 'user'])->inRandomOrder()->get()->first();
$message = (new ContentLicense($license))->toMail(User::first());
return app(Markdown::class)->render($message->markdown, $message->data());
});
another option I explored is putting render() inside the Notification class
// Notifications/ContentLicense.php
public function render($notifiable)
{
// $markdown = new \Illuminate\Mail\Markdown(view(), config('mail.markdown'));
$message = $this->toMail($notifiable);
return app(Markdown::class)->render($message->markdown, $this->toArray($notifiable));
}
...
// route
Route::get('/mailable/content-license', function() {
$license = License::with(['content', 'user'])->inRandomOrder()->get()->first();
return (new ContentLicense($license))->render(User::first());
});
I think it'd be a cool feature similar to using Mail, I could PR a solution but I know that it would be good to support \Illuminate\Contracts\Support\Renderable which takes no parameters, where w/ this we need to pass in a type of $notifiable.
If anyone has any other ideas how this could be done LMK!
This issue reads like a chat entry. What do you want to accomplish with this issue?
@sisve it's quite simple, mailable's have a render() allowing them to be rendered on the web. Documentation can be found here . This is not possible for MailMessage mails from Notifications. I'm proposing we add it.
This way people aren't having to write what I did above, or google it and find stuff like this
I'd like to see this reopened. It would be nice to see \Illuminate\Auth\Notifications\ResetPassword using a simple $mailMessage->render() method, just as it works for Mailable objects.
Most helpful comment
I'd like to see this reopened. It would be nice to see
\Illuminate\Auth\Notifications\ResetPasswordusing a simple$mailMessage->render()method, just as it works forMailableobjects.