2020-05-25 07:45:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
2022-03-05 00:05:35 +00:00
|
|
|
use Illuminate\Support\Facades\Config;
|
2020-05-25 07:45:17 +00:00
|
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
use App\Models\Invoice;
|
|
|
|
|
|
|
|
class InvoiceEmail extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'invoice:email {id}';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Email Invoices to be client';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$o = Invoice::findOrFail($this->argument('id'));
|
2022-03-05 00:05:35 +00:00
|
|
|
Config::set('site',$o->account->site);
|
2020-05-25 07:45:17 +00:00
|
|
|
|
|
|
|
Mail::to($o->account->user->email)->send(new \App\Mail\InvoiceEmail($o));
|
|
|
|
|
|
|
|
if (Mail::failures()) {
|
|
|
|
dump('Failure?');
|
|
|
|
|
|
|
|
dump(Mail::failures());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$o->print_status = TRUE;
|
|
|
|
$o->reminders = $o->reminders('send');
|
|
|
|
$o->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|