mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-01 03:55:57 +00:00
invoice to mail
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Http\Resources\Oasis\OasisInvoiceResource;
|
||||
use App\Models\Oasis\Client;
|
||||
use App\Models\Oasis\Invoice;
|
||||
use App\Notifications\Oasis\InvoiceDeliveryNotification;
|
||||
use App\Notifications\SharedSendViaEmail;
|
||||
use Auth;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
@@ -96,12 +97,13 @@ class InvoiceController extends Controller
|
||||
->setPaper('a4')
|
||||
->setOrientation('portrait')
|
||||
->save(
|
||||
storage_path("/app/files/{$request->user()->id}/invoice-{$invoice->id}.pdf")
|
||||
storage_path("app/files/{$request->user()->id}/invoice-{$invoice->id}.pdf")
|
||||
);
|
||||
|
||||
if ($request->send_invoice && $invoice->client['email']) {
|
||||
Notification::route('mail', $invoice->client['email'])
|
||||
->notify(new InvoiceDeliveryNotification($request->user()));
|
||||
Notification::route('mail', $invoice->client['email'])->notify(
|
||||
new InvoiceDeliveryNotification($request->user(), $invoice)
|
||||
);
|
||||
}
|
||||
|
||||
return response(
|
||||
|
||||
@@ -15,19 +15,30 @@ function is_route($name)
|
||||
* @param $filepath
|
||||
* @return string
|
||||
*/
|
||||
function get_storage_path($filepath)
|
||||
function base64_from_storage_image($filepath)
|
||||
{
|
||||
if (is_null($filepath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! Storage::exists($filepath)) {
|
||||
if (!Storage::exists($filepath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return 'data:' . Storage::mimeType($filepath) . ';base64,' . base64_encode(Storage::get($filepath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return invoice path to storage
|
||||
*
|
||||
* @param $invoice
|
||||
* @return string
|
||||
*/
|
||||
function invoice_path($invoice)
|
||||
{
|
||||
return "files/{$invoice->user_id}/invoice-{$invoice->id}.pdf";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get only tax for single invoice item
|
||||
*
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Notifications\Oasis;
|
||||
|
||||
use App\Models\Oasis\Invoice;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
@@ -11,14 +12,19 @@ class InvoiceDeliveryNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
private $invoice;
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @param $user
|
||||
* @param $invoice
|
||||
*/
|
||||
public function __construct($user)
|
||||
public function __construct($user, $invoice)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +50,11 @@ class InvoiceDeliveryNotification extends Notification
|
||||
->subject('New invoice')
|
||||
->greeting(__t('mail_greeting'))
|
||||
->line($this->user->settings->name . ' sent you an invoice.')
|
||||
->salutation(__t('mail_salutation'));
|
||||
->salutation(__t('mail_salutation'))
|
||||
->attach(storage_path("app/" . invoice_path($this->invoice)), [
|
||||
'as' => 'name.pdf',
|
||||
'mime' => 'application/pdf',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user