feat(api): organisation email branding and shared mail layout
- Add email branding columns to organisations table (logo, color, reply-to, sender name, footer)
- Create MailBrandingService for resolving per-org branding with defaults
- Create CrewliMailable abstract base class with branded from/reply-to
- Create shared Blade layout (mail.layouts.crewli) with inline CSS
- Refactor Registration*Mail and InvitationMail to extend CrewliMailable
- Add config/crewli.php for platform-wide defaults (portal_url, app_url, logo)
- Add dev-only /mail-preview/{type} route for browser email previewing
- Update Organisation model, resource, and form requests with branding fields
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
41
api/app/Mail/CrewliMailable.php
Normal file
41
api/app/Mail/CrewliMailable.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Organisation;
|
||||
use App\Services\MailBrandingService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
abstract class CrewliMailable extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected Organisation $organisation;
|
||||
|
||||
public function __construct(Organisation $organisation)
|
||||
{
|
||||
$this->organisation = $organisation;
|
||||
}
|
||||
|
||||
protected function buildBranding(): static
|
||||
{
|
||||
$branding = app(MailBrandingService::class)->getBranding($this->organisation);
|
||||
|
||||
$this->from(
|
||||
config('mail.from.address'),
|
||||
$branding['sender_name']
|
||||
);
|
||||
|
||||
if ($branding['reply_to']) {
|
||||
$this->replyTo($branding['reply_to']);
|
||||
}
|
||||
|
||||
return $this->with('branding', $branding);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user