Skip to content

Commit

Permalink
Merge pull request #11 from mlltddevelopment/main
Browse files Browse the repository at this point in the history
Fix form submission, make redirect route configurable, and add Mailable to readme
  • Loading branch information
mwagena authored Mar 18, 2024
2 parents e768f40 + e42afef commit b2a5706
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
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
1 change: 1 addition & 0 deletions config/filament-invite.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
// config for Concept7/FilamentInvite
return [
'expiration_time_in_hours' => '24',
'after_login_redirect_route' => 'filament.admin.pages.dashboard',
];
6 changes: 6 additions & 0 deletions src/FilamentInviteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Livewire\Livewire;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Session\Middleware\StartSession;

class FilamentInviteServiceProvider extends PackageServiceProvider
{
Expand Down Expand Up @@ -69,6 +71,10 @@ public function panel(Panel $panel): Panel
return $panel
->id('invite')
->path('invite')
->middleware([
EncryptCookies::class,
StartSession::class,
])
->pages([
Accept::class,
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Livewire/Accept.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function submit()
return route('filament.auth.login');
}

return redirect()->intended(route('filament.admin.pages.dashboard'));
return redirect()->intended(route(config('filament-invite.after_login_redirect_route')));

}

Expand Down

0 comments on commit b2a5706

Please sign in to comment.