- Map all forms from your application and send them to specific emails
composer require agenciafmd/admix-postal:dev-master
Run the migrations
php artisan migrate
If you want to use the seeder, run
php artisan vendor:publish --tag=admix-postal:seeders
// if you want to send attachments
$attachments = null;
if ($request->has('images')) {
$images = $request->file('images');
foreach ($images as $image) {
$customName = Str::of($request->name)->slug() . '-' . Str::random(5) . '.' . $image->getClientOriginalExtension();
/* TODO: refactor with Storage */
$attachments[] = storage_path(
'app/' . $image
->storeAs('attachments', $customName, 'local')
);
}
}
// fill if you want to customize the subject
$customSubject = null;
Postal::query()
->where('slug', 'slug-of-created-form')
->first()
->notify(new SendNotification([
'greeting' => $request->subject,
'introLines' => [
'**Nome:** ' . $request->name,
'**E-mail:** ' . $request->email,
'**Telefone:** ' . $request->phone,
'**Cidade:** ' . $request->city . ' - ' . $request->state,
'**Mensagem:** ' . nl2br($request->message),
],
], [$request->email => $request->name], $attachments, $customSubject));