feat(Notification process: text, app name, membership validation + project update)
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 1m21s
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 1m21s
This commit is contained in:
@@ -57,7 +57,8 @@ class MembershipForm
|
||||
TextEntry::make('member.full_name')
|
||||
->label(Membership::getAttributeLabel('member_id')),
|
||||
TextEntry::make('author.name')
|
||||
->label(Membership::getAttributeLabel('admin_id')),
|
||||
->label(Membership::getAttributeLabel('admin_id'))
|
||||
->default(__('memberships.sections.author_not_set')),
|
||||
TextEntry::make('created_at')
|
||||
->label(Membership::getAttributeLabel('created_at')),
|
||||
])
|
||||
|
||||
@@ -12,6 +12,17 @@ class MembershipRequest extends FormRequest
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'phone1.digits' => 'Le numéro de téléphone doit contenir exactement 10 chiffres.',
|
||||
'zipcode.digits' => 'Le code postal doit contenir exactement 5 chiffres.',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
@@ -23,9 +34,9 @@ class MembershipRequest extends FormRequest
|
||||
'email' => 'required|email|max:255',
|
||||
'company' => 'nullable|string|max:255',
|
||||
'address' => 'required|string|max:255',
|
||||
'zipcode' => 'required|string|max:255',
|
||||
'zipcode' => ['required', 'digits:5'],
|
||||
'city' => 'required|string|max:255',
|
||||
'phone1' => 'required|string|max:255',
|
||||
'phone1' => ['required', 'digits:10'],
|
||||
'package' => 'required|string|max:255',
|
||||
'amount' => 'required|numeric|min:0',
|
||||
'cgu' => 'required|accepted',
|
||||
|
||||
@@ -29,7 +29,7 @@ class MemberDeactivatedMemberNotification extends Notification implements Should
|
||||
|
||||
$vars = [
|
||||
'member_name' => $this->member->full_name,
|
||||
'app_name' => config('app.name'),
|
||||
'app_name' => config('app.front_name'),
|
||||
];
|
||||
|
||||
return (new MailMessage)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Filament\Resources\Members\MemberResource;
|
||||
use App\Models\Member;
|
||||
use App\Models\NotificationTemplate;
|
||||
use App\Models\Package;
|
||||
@@ -19,6 +18,7 @@ class MemberNewRequestAdminNotification extends Notification implements ShouldQu
|
||||
public readonly Member $member,
|
||||
public readonly Package $package,
|
||||
public readonly float $amount,
|
||||
public readonly string $membershipUrl,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -44,7 +44,7 @@ class MemberNewRequestAdminNotification extends Notification implements ShouldQu
|
||||
])),
|
||||
'package_name' => $this->package->name,
|
||||
'amount' => number_format($this->amount, 2, ',', ' '),
|
||||
'member_url' => MemberResource::getUrl('edit', ['record' => $this->member->id]),
|
||||
'membership_url' => $this->membershipUrl,
|
||||
'app_name' => config('app.name'),
|
||||
];
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class MemberNewRequestMemberNotification extends Notification implements ShouldQ
|
||||
$vars = [
|
||||
'member_name' => $this->member->full_name,
|
||||
'package_name' => $this->package->name,
|
||||
'app_name' => 'Le Retzien Libre',
|
||||
'app_name' => config('app.front_name'),
|
||||
];
|
||||
|
||||
return (new MailMessage)
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Notifications;
|
||||
|
||||
use App\Models\Membership;
|
||||
use App\Models\NotificationTemplate;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
@@ -30,9 +31,9 @@ class MembershipValidatedNotification extends Notification implements ShouldQueu
|
||||
$vars = [
|
||||
'member_name' => $this->membership->member->full_name,
|
||||
'package_name' => $this->membership->package->name,
|
||||
'start_date' => $this->membership->start_date?->format('d/m/Y') ?? '',
|
||||
'end_date' => $this->membership->end_date?->format('d/m/Y') ?? '',
|
||||
'app_name' => config('app.name'),
|
||||
'start_date' => $this->membership->start_date ? Carbon::parse($this->membership->start_date)->format('d/m/Y') : '',
|
||||
'end_date' => $this->membership->end_date ? Carbon::parse($this->membership->end_date)->format('d/m/Y') : '',
|
||||
'app_name' => config('app.front_name'),
|
||||
];
|
||||
|
||||
return (new MailMessage)
|
||||
|
||||
@@ -35,6 +35,7 @@ class SubscriptionExpiredPhase1 extends Notification implements ShouldQueue
|
||||
->subject($this->template->renderSubject($vars))
|
||||
->view('notifications.mail-template', [
|
||||
'body' => $this->template->renderBody($vars),
|
||||
'appName' => config('app.front_name'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,11 @@ namespace App\Providers;
|
||||
use App\Listeners\PreprodMailInterceptor;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Mail\Events\MessageSending;
|
||||
use Illuminate\Queue\Events\JobFailed;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Queue;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -26,5 +29,13 @@ class AppServiceProvider extends ServiceProvider
|
||||
JsonResource::withoutWrapping();
|
||||
|
||||
Event::listen(MessageSending::class, PreprodMailInterceptor::class);
|
||||
|
||||
// Log failed jobs
|
||||
Queue::failing(function (JobFailed $event) {
|
||||
Log::error('Job failed: '.$event->job->resolveName(), [
|
||||
'exception' => $event->exception->getMessage(),
|
||||
'trace' => $event->exception->getTraceAsString(),
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,16 +45,17 @@ class MemberService
|
||||
->firstOrFail();
|
||||
|
||||
// Create a new membership
|
||||
$member->memberships()->create([
|
||||
$membership = $member->memberships()->create([
|
||||
'status' => 'pending',
|
||||
'package_id' => $package->id ?? null,
|
||||
'amount' => $data['amount'],
|
||||
'payment_status' => 'unpaid',
|
||||
|
||||
]);
|
||||
|
||||
$membershipUrl = route('filament.admin.resources.memberships.edit', ['record' => $membership->id]);
|
||||
|
||||
Notification::route('mail', config('app.admin_email'))
|
||||
->notify(new MemberNewRequestAdminNotification($member, $package, (float) $data['amount']));
|
||||
->notify(new MemberNewRequestAdminNotification($member, $package, (float) $data['amount'], $membershipUrl));
|
||||
|
||||
$member->notify(new MemberNewRequestMemberNotification($member, $package));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user