1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 14:12:44 +01:00

Static analysis cleanup

This commit is contained in:
David Bomba 2023-04-27 07:13:45 +10:00
parent 7ef552431c
commit bffa1cf894
4 changed files with 35 additions and 26 deletions

View File

@ -48,16 +48,19 @@ class AutoBill implements ShouldQueue
MultiDB::setDb($this->db);
}
$invoice = false;
try {
nlog("autobill {$this->invoice_id}");
$invoice = Invoice::withTrashed()->find($this->invoice_id);
$invoice->service()->autoBill();
} catch (\Exception $e) {
nlog("Failed to capture payment for {$this->invoice_id} ->".$e->getMessage());
if($this->send_email_on_failure)
if($this->send_email_on_failure && $invoice)
{
$invoice->invitations->each(function ($invitation) use ($invoice) {

View File

@ -61,7 +61,7 @@ class EmailEntity implements ShouldQueue
* EmailEntity constructor.
*
*
* @param Invitation $invitation
* @param mixed $invitation
* @param Company $company
* @param ?string $reminder_template
* @param array $template_data
@ -146,21 +146,26 @@ class EmailEntity implements ShouldQueue
} elseif ($this->invitation instanceof RecurringInvoiceInvitation) {
return 'recurring_invoice';
}
return '';
}
/* Switch statement to handle failure notifications */
private function entityEmailFailed($message)
{
switch ($this->entity_string) {
case 'invoice':
event(new InvoiceWasEmailedAndFailed($this->invitation, $this->company, $message, $this->reminder_template, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
break;
/**
* @deprecated
* @unused
*/
// private function entityEmailFailed($message)
// {
// switch ($this->entity_string) {
// case 'invoice':
// event(new InvoiceWasEmailedAndFailed($this->invitation, $this->company, $message, $this->reminder_template, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
// break;
default:
// code...
break;
}
}
// default:
// // code...
// break;
// }
// }
/* Builds the email builder object */
private function resolveEmailBuilder()

View File

@ -96,6 +96,8 @@ use Laracasts\Presenter\PresentableTrait;
* @property-read mixed $hashed_id
* @property-read mixed $status
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Client> $client
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Company> $company
* @property-read int|null $history_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\RecurringInvoiceInvitation> $invitations
* @property-read int|null $invitations_count

View File

@ -11,26 +11,25 @@
namespace App\Models;
use App\Models\Company;
use App\Utils\TruthSource;
use App\Jobs\Mail\NinjaMailer;
use Illuminate\Support\Carbon;
use App\Utils\Traits\MakesHash;
use App\Jobs\Mail\NinjaMailerJob;
use App\Services\User\UserService;
use App\Utils\Traits\UserSettings;
use App\Jobs\Mail\NinjaMailerObject;
use App\Mail\Admin\ResetPasswordObject;
use Illuminate\Database\Eloquent\Model;
use App\Models\Presenters\UserPresenter;
use App\Notifications\ResetPasswordNotification;
use App\Services\User\UserService;
use App\Utils\Traits\MakesHash;
use Illuminate\Notifications\Notifiable;
use Laracasts\Presenter\PresentableTrait;
use App\Utils\Traits\UserSessionAttributes;
use App\Utils\Traits\UserSettings;
use App\Utils\TruthSource;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
use Laracasts\Presenter\PresentableTrait;
/**
* App\Models\User
@ -178,7 +177,7 @@ class User extends Authenticatable implements MustVerifyEmail
protected $dateFormat = 'Y-m-d H:i:s.u';
public $company;
public Company $company;
protected $appends = [
'hashed_id',