agenciafmd/admix-postal

There is no license information available for the latest version (1.0.0) of this package.

Postal - Agência F&MD

1.0.0 2019-11-06 13:52 UTC

This package is auto-updated.

Last update: 2025-01-22 18:30:09 UTC


README

Área Administrativa

Downloads Licença

  • Map all forms from your application and send them to specific emails

Installation

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

Usage

    // 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));