Skip to content

Commit

Permalink
update README , re the mailable
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMcRoarSoftware committed Dec 20, 2023
1 parent 94ea443 commit e42afef
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,67 @@ php artisan vendor:publish --tag="filament-invite-views"
use Concept7\FilamentInvite\Models\Traits\Invitable;
```

### Create a mailable

In app/Mail, create SendInviteMail.php, e.g.

```
<?php

namespace App\Mail;

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 App\Models\User;
use Concept7\FilamentInvite\Contracts\SendInviteMail as SendInviteMailContract;

class SendInviteMail extends Mailable implements SendInviteMailContract
{
use Queueable, SerializesModels;

/**
* Create a new message instance.
/**
* Create a new message instance.
*/
public function __construct(
private User $user,
private $url
) {
//
}

/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
to: $this->user->email,
subject: 'You are invited to join ' . config('app.name'),
);
}

/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
markdown: 'filament-invite::mail.invite',
with: [
'user' => $this->user,
'link' => $this->url,
]
);
}
}
```

### Event listener
If for some reason you need to listen to the InviteAccepted Event, you can register a listener handling a InviteProcessedEvent.
Register the listener in your EventServiceProvider.
Expand Down

0 comments on commit e42afef

Please sign in to comment.