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;
|
|
|
|
|
2022-08-25 01:08:10 +00:00
|
|
|
use App\Models\{Invoice,Site};
|
2020-05-25 07:45:17 +00:00
|
|
|
|
|
|
|
class InvoiceEmail extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2022-08-25 01:08:10 +00:00
|
|
|
protected $signature = 'invoice:email {site} {id}';
|
2020-05-25 07:45:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Email Invoices to be client';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2022-08-25 01:08:10 +00:00
|
|
|
Config::set('site',Site::findOrFail($this->argument('site')));
|
|
|
|
|
2020-05-25 07:45:17 +00:00
|
|
|
$o = Invoice::findOrFail($this->argument('id'));
|
|
|
|
|
|
|
|
Mail::to($o->account->user->email)->send(new \App\Mail\InvoiceEmail($o));
|
|
|
|
|
2022-05-12 04:34:14 +00:00
|
|
|
try {
|
2020-05-25 07:45:17 +00:00
|
|
|
$o->print_status = TRUE;
|
|
|
|
$o->reminders = $o->reminders('send');
|
|
|
|
$o->save();
|
2022-05-12 04:34:14 +00:00
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
dd($e);
|
2020-05-25 07:45:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|