mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 00:34:35 -04:00
Fix companygatewaytransformer (#3677)
* Working on subscriptions * Implement return type in models * Subscription implementation * Improvements to handling importation of large accountS * Loggin imports * Activate collector * Improve memory usage of import script * Appen Tags into emails - fix companygatewaytransformer
This commit is contained in:
parent
b0968b6aff
commit
b3eb2ae3b4
@ -77,6 +77,18 @@ class MigrationController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function purgeCompany(Company $company)
|
public function purgeCompany(Company $company)
|
||||||
{
|
{
|
||||||
|
// $account = $company->account;
|
||||||
|
|
||||||
|
// if($account->default_company_id == $company->id)
|
||||||
|
// {
|
||||||
|
// $companies = $account->companies;
|
||||||
|
|
||||||
|
// if($companies->count() > 1)
|
||||||
|
// {
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
$company->delete();
|
$company->delete();
|
||||||
|
|
||||||
return response()->json(['message' => 'Company purged'], 200);
|
return response()->json(['message' => 'Company purged'], 200);
|
||||||
@ -207,6 +219,9 @@ class MigrationController extends BaseController
|
|||||||
$account = auth()->user()->account;
|
$account = auth()->user()->account;
|
||||||
$company = (new ImportMigrations())->getCompany($account);
|
$company = (new ImportMigrations())->getCompany($account);
|
||||||
|
|
||||||
|
$account->default_company_id = $company->id;
|
||||||
|
$account->save();
|
||||||
|
|
||||||
$company_token = new CompanyToken();
|
$company_token = new CompanyToken();
|
||||||
$company_token->user_id = $user->id;
|
$company_token->user_id = $user->id;
|
||||||
$company_token->company_id = $company->id;
|
$company_token->company_id = $company->id;
|
||||||
@ -262,6 +277,10 @@ class MigrationController extends BaseController
|
|||||||
$account = auth()->user()->account;
|
$account = auth()->user()->account;
|
||||||
$company = (new ImportMigrations())->getCompany($account);
|
$company = (new ImportMigrations())->getCompany($account);
|
||||||
|
|
||||||
|
$account->default_company_id = $company->id;
|
||||||
|
$account->save();
|
||||||
|
|
||||||
|
|
||||||
$company_token = new CompanyToken();
|
$company_token = new CompanyToken();
|
||||||
$company_token->user_id = $user->id;
|
$company_token->user_id = $user->id;
|
||||||
$company_token->company_id = $company->id;
|
$company_token->company_id = $company->id;
|
||||||
@ -291,6 +310,10 @@ class MigrationController extends BaseController
|
|||||||
$account = auth()->user()->account;
|
$account = auth()->user()->account;
|
||||||
$company = (new ImportMigrations())->getCompany($account);
|
$company = (new ImportMigrations())->getCompany($account);
|
||||||
|
|
||||||
|
$account->default_company_id = $company->id;
|
||||||
|
$account->save();
|
||||||
|
|
||||||
|
|
||||||
$company_token = new CompanyToken();
|
$company_token = new CompanyToken();
|
||||||
$company_token->user_id = $user->id;
|
$company_token->user_id = $user->id;
|
||||||
$company_token->company_id = $company->id;
|
$company_token->company_id = $company->id;
|
||||||
|
@ -147,6 +147,9 @@ class Import implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
set_time_limit(0);
|
||||||
|
|
||||||
foreach ($this->data as $key => $resource) {
|
foreach ($this->data as $key => $resource) {
|
||||||
if (! in_array($key, $this->available_imports)) {
|
if (! in_array($key, $this->available_imports)) {
|
||||||
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
||||||
@ -193,6 +196,12 @@ class Import implements ShouldQueue
|
|||||||
$company_repository->save($data, $this->company);
|
$company_repository->save($data, $this->company);
|
||||||
|
|
||||||
Company::reguard();
|
Company::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
|
$rules = null;
|
||||||
|
$validator = null;
|
||||||
|
$company_repository = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function transformCompanyData(array $data): array
|
private function transformCompanyData(array $data): array
|
||||||
@ -258,6 +267,11 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
TaxRate::reguard();
|
TaxRate::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
|
$rules = null;
|
||||||
|
$validator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -305,6 +319,12 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
User::reguard();
|
User::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
|
$rules = null;
|
||||||
|
$validator = null;
|
||||||
|
$user_repository = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -358,6 +378,11 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
Client::reguard();
|
Client::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
|
$contact_repository = null;
|
||||||
|
$client_repository = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processProducts(array $data): void
|
private function processProducts(array $data): void
|
||||||
@ -396,6 +421,10 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
Product::reguard();
|
Product::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
|
$product_repository = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processInvoices(array $data): void
|
private function processInvoices(array $data): void
|
||||||
@ -414,7 +443,8 @@ class Import implements ShouldQueue
|
|||||||
|
|
||||||
$invoice_repository = new InvoiceRepository();
|
$invoice_repository = new InvoiceRepository();
|
||||||
|
|
||||||
foreach ($data as $resource) {
|
foreach ($data as $key => $resource) {
|
||||||
|
|
||||||
$modified = $resource;
|
$modified = $resource;
|
||||||
|
|
||||||
if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) {
|
if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) {
|
||||||
@ -442,6 +472,11 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
Invoice::reguard();
|
Invoice::reguard();
|
||||||
|
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
|
$invoice_repository = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processCredits(array $data): void
|
private function processCredits(array $data): void
|
||||||
@ -487,6 +522,10 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
Credit::reguard();
|
Credit::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
|
$credit_repository = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processQuotes(array $data): void
|
private function processQuotes(array $data): void
|
||||||
@ -535,6 +574,10 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
Quote::reguard();
|
Quote::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
|
$quote_repository = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processPayments(array $data): void
|
private function processPayments(array $data): void
|
||||||
@ -570,6 +613,7 @@ class Import implements ShouldQueue
|
|||||||
unset($modified['invoice_id']);
|
unset($modified['invoice_id']);
|
||||||
|
|
||||||
if (isset($modified['invoices'])) {
|
if (isset($modified['invoices'])) {
|
||||||
|
|
||||||
foreach ($modified['invoices'] as $invoice) {
|
foreach ($modified['invoices'] as $invoice) {
|
||||||
$invoice['invoice_id'] = $this->transformId('invoices', $invoice['invoice_id']);
|
$invoice['invoice_id'] = $this->transformId('invoices', $invoice['invoice_id']);
|
||||||
}
|
}
|
||||||
@ -591,6 +635,10 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
Payment::reguard();
|
Payment::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
|
$payment_repository = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processDocuments(array $data): void
|
private function processDocuments(array $data): void
|
||||||
@ -642,6 +690,9 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
Document::reguard();
|
Document::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processCompanyGateways(array $data) :void
|
private function processCompanyGateways(array $data) :void
|
||||||
@ -688,6 +739,9 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
CompanyGateway::reguard();
|
CompanyGateway::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processClientGatewayTokens(array $data) :void
|
private function processClientGatewayTokens(array $data) :void
|
||||||
@ -715,6 +769,9 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
ClientGatewayToken::reguard();
|
ClientGatewayToken::reguard();
|
||||||
|
|
||||||
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
|
$data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,24 +2,34 @@
|
|||||||
|
|
||||||
namespace App\Jobs\Util;
|
namespace App\Jobs\Util;
|
||||||
|
|
||||||
|
use App\Models\Subscription;
|
||||||
|
use App\Transformers\ArraySerializer;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use League\Fractal\Manager;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
class SubscriptionHandler implements ShouldQueue
|
class SubscriptionHandler implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
private $entity;
|
||||||
|
|
||||||
|
private $event_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
|
||||||
|
public function __construct($event_id, $entity)
|
||||||
{
|
{
|
||||||
//
|
$this->event_id = $event_id;
|
||||||
|
$this->entity = $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,6 +39,55 @@ class SubscriptionHandler implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
//
|
$subscriptions = Subscription::where('company_id', $this->entity->company_id)
|
||||||
|
->where('event_id', $this->event_id)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if(!$subscriptions || $subscriptions->count() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$subscriptions->each(function($subscription) {
|
||||||
|
$this->process($subscription);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function process($subscription)
|
||||||
|
{
|
||||||
|
// generate JSON data
|
||||||
|
$manager = new Manager();
|
||||||
|
$manager->setSerializer(new ArraySerializer());
|
||||||
|
$manager->parseIncludes($include);
|
||||||
|
|
||||||
|
$transformer = new $this->getTransformerClassName();
|
||||||
|
|
||||||
|
$resource = new Item($this->entity, $transformer, $this->entity->getEntityType());
|
||||||
|
$data = $manager->createData($resource)->toArray();
|
||||||
|
|
||||||
|
$this->postData($subscription, $data, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getTransformerClassName()
|
||||||
|
{
|
||||||
|
return sprintf('App\\Transformers\\%sTransformer', class_basename($this->entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function postData($subscription, $data, $headers = [])
|
||||||
|
{
|
||||||
|
$base_headers = [
|
||||||
|
'Content-Length' => strlen($data),
|
||||||
|
'Accept' => 'application/json'
|
||||||
|
];
|
||||||
|
|
||||||
|
$client = new \GuzzleHttp\Client(['headers' => array_merge($base_headers, $headers)]);
|
||||||
|
|
||||||
|
//$response = $client->request('POST', $subscription->target_url, ['form_params' => $data]);
|
||||||
|
|
||||||
|
$response = $client->post($subscription->target_url, [
|
||||||
|
GuzzleHttp\RequestOptions::JSON => $data // or 'json' => [...]
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->getStatusCode() == 410 || $response->getStatusCode() == 200) {
|
||||||
|
$subscription->delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,12 @@ class Account extends BaseModel
|
|||||||
|
|
||||||
const RESULT_FAILURE = 'failure';
|
const RESULT_FAILURE = 'failure';
|
||||||
const RESULT_SUCCESS = 'success';
|
const RESULT_SUCCESS = 'success';
|
||||||
/**
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
||||||
*/
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Account::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function users()
|
public function users()
|
||||||
{
|
{
|
||||||
|
@ -79,6 +79,12 @@ class Activity extends StaticModel
|
|||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Activity::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function backup()
|
public function backup()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Backup::class);
|
return $this->hasOne(Backup::class);
|
||||||
|
@ -18,6 +18,12 @@ use Laracasts\Presenter\PresentableTrait;
|
|||||||
|
|
||||||
class Backup extends BaseModel
|
class Backup extends BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Backup::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function activity()
|
public function activity()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Activity::class);
|
return $this->belongsTo(Activity::class);
|
||||||
|
@ -32,4 +32,10 @@ class Bank extends StaticModel
|
|||||||
|
|
||||||
return new \App\Libraries\Bank($finance, $config->fid, $config->url, $config->org);
|
return new \App\Libraries\Bank($finance, $config->fid, $config->url, $config->org);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Bank::class;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,4 +67,10 @@ class BankAccount extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\BankSubaccount');
|
return $this->hasMany('App\Models\BankSubaccount');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return BankAccount::class;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,11 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Client::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function ledger()
|
public function ledger()
|
||||||
{
|
{
|
||||||
return $this->hasMany(CompanyLedger::class);
|
return $this->hasMany(CompanyLedger::class);
|
||||||
|
@ -86,6 +86,11 @@ class ClientContact extends Authenticatable implements HasLocalePreference
|
|||||||
'is_primary',
|
'is_primary',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return ClientContact::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHashedIdAttribute()
|
public function getHashedIdAttribute()
|
||||||
{
|
{
|
||||||
return $this->encodePrimaryKey($this->id);
|
return $this->encodePrimaryKey($this->id);
|
||||||
|
@ -29,6 +29,11 @@ class ClientGatewayToken extends BaseModel
|
|||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return ClientGatewayToken::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function client()
|
public function client()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Client::class)->withTrashed();
|
return $this->hasOne(Client::class)->withTrashed();
|
||||||
|
@ -133,6 +133,11 @@ class Company extends BaseModel
|
|||||||
self::ENTITY_RECURRING_QUOTE => 2048,
|
self::ENTITY_RECURRING_QUOTE => 2048,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Company::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function ledger()
|
public function ledger()
|
||||||
{
|
{
|
||||||
return $this->hasMany(CompanyLedger::class);
|
return $this->hasMany(CompanyLedger::class);
|
||||||
|
@ -55,6 +55,11 @@ class CompanyGateway extends BaseModel
|
|||||||
// return json_decode($this->attributes['fees_and_limits']);
|
// return json_decode($this->attributes['fees_and_limits']);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return CompanyGateway::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
|
@ -27,6 +27,11 @@ class CompanyLedger extends Model
|
|||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return CompanyLedger::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
|
@ -27,6 +27,11 @@ class CompanyToken extends BaseModel
|
|||||||
protected $with = [
|
protected $with = [
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return CompanyToken::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function account()
|
public function account()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Account::class);
|
return $this->belongsTo(Account::class);
|
||||||
|
@ -48,6 +48,11 @@ class CompanyUser extends Pivot
|
|||||||
'slack_webhook_url',
|
'slack_webhook_url',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return CompanyUser::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function account()
|
public function account()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Account::class);
|
return $this->belongsTo(Account::class);
|
||||||
|
@ -80,6 +80,11 @@ class Credit extends BaseModel
|
|||||||
const STATUS_PARTIAL = 3;
|
const STATUS_PARTIAL = 3;
|
||||||
const STATUS_APPLIED = 4;
|
const STATUS_APPLIED = 4;
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Credit::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDateAttribute($value)
|
public function getDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
|
@ -36,6 +36,11 @@ class CreditInvitation extends BaseModel
|
|||||||
// 'company',
|
// 'company',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return CreditInvitation::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getSignatureDateAttribute($value)
|
public function getSignatureDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!$value) {
|
if (!$value) {
|
||||||
|
@ -88,6 +88,10 @@ class Document extends BaseModel
|
|||||||
'tif' => 'tiff',
|
'tif' => 'tiff',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Document::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function documentable()
|
public function documentable()
|
||||||
{
|
{
|
||||||
|
@ -60,6 +60,10 @@ class Expense extends BaseModel
|
|||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Expense::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function documents()
|
public function documents()
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,11 @@ class ExpenseCategory extends BaseModel
|
|||||||
'name',
|
'name',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return ExpenseCategory::class;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
|
@ -131,6 +131,11 @@ class Invoice extends BaseModel
|
|||||||
const STATUS_OVERDUE = -1; //status < 4 || < 3 && !is_deleted && !trashed() && due_date < now()
|
const STATUS_OVERDUE = -1; //status < 4 || < 3 && !is_deleted && !trashed() && due_date < now()
|
||||||
const STATUS_UNPAID = -2; //status < 4 || < 3 && !is_deleted && !trashed()
|
const STATUS_UNPAID = -2; //status < 4 || < 3 && !is_deleted && !trashed()
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Invoice::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDateAttribute($value)
|
public function getDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
|
@ -35,6 +35,10 @@ class InvoiceInvitation extends BaseModel
|
|||||||
// 'company',
|
// 'company',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return InvoiceInvitation::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getSignatureDateAttribute($value)
|
public function getSignatureDateAttribute($value)
|
||||||
{
|
{
|
||||||
|
@ -79,6 +79,11 @@ class Payment extends BaseModel
|
|||||||
'paymentables',
|
'paymentables',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Payment::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function client()
|
public function client()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Client::class)->withTrashed();
|
return $this->belongsTo(Client::class)->withTrashed();
|
||||||
|
@ -40,6 +40,11 @@ class Product extends BaseModel
|
|||||||
'tax_rate3',
|
'tax_rate3',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Product::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
|
@ -37,6 +37,11 @@ class Project extends BaseModel
|
|||||||
'created_at' => 'timestamp',
|
'created_at' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Project::class;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
|
@ -22,6 +22,11 @@ class Proposal extends BaseModel
|
|||||||
'id',
|
'id',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Proposal::class;
|
||||||
|
}
|
||||||
|
|
||||||
protected $appends = ['proposal_id'];
|
protected $appends = ['proposal_id'];
|
||||||
|
|
||||||
public function getRouteKeyName()
|
public function getRouteKeyName()
|
||||||
|
@ -86,6 +86,11 @@ class Quote extends BaseModel
|
|||||||
const STATUS_APPROVED = 3;
|
const STATUS_APPROVED = 3;
|
||||||
const STATUS_EXPIRED = -1;
|
const STATUS_EXPIRED = -1;
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Quote::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDateAttribute($value)
|
public function getDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
|
@ -30,6 +30,11 @@ class QuoteInvitation extends BaseModel
|
|||||||
'client_contact_id',
|
'client_contact_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return QuoteInvitation::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getSignatureDateAttribute($value)
|
public function getSignatureDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!$value) {
|
if (!$value) {
|
||||||
|
@ -111,6 +111,11 @@ class RecurringInvoice extends BaseModel
|
|||||||
'status'
|
'status'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return RecurringInvoice::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDateAttribute($value)
|
public function getDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
|
@ -18,6 +18,11 @@ class RecurringInvoiceInvitation extends BaseModel
|
|||||||
{
|
{
|
||||||
use MakesDates;
|
use MakesDates;
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return RecurringInvoiceInvitation::class;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -94,6 +94,11 @@ class RecurringQuote extends BaseModel
|
|||||||
// 'company',
|
// 'company',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return RecurringQuote::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDateAttribute($value)
|
public function getDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
|
@ -35,6 +35,11 @@ class Task extends BaseModel
|
|||||||
'created_at' => 'timestamp',
|
'created_at' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Task::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function documents()
|
public function documents()
|
||||||
{
|
{
|
||||||
return $this->morphMany(Document::class, 'documentable');
|
return $this->morphMany(Document::class, 'documentable');
|
||||||
|
@ -27,6 +27,11 @@ class TaxRate extends BaseModel
|
|||||||
|
|
||||||
protected $appends = ['tax_rate_id'];
|
protected $appends = ['tax_rate_id'];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return TaxRate::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getRouteKeyName()
|
public function getRouteKeyName()
|
||||||
{
|
{
|
||||||
return 'tax_rate_id';
|
return 'tax_rate_id';
|
||||||
|
@ -101,6 +101,11 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
//'last_login' => 'timestamp',
|
//'last_login' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return User::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHashedIdAttribute()
|
public function getHashedIdAttribute()
|
||||||
{
|
{
|
||||||
return $this->encodePrimaryKey($this->id);
|
return $this->encodePrimaryKey($this->id);
|
||||||
|
@ -57,6 +57,11 @@ class Vendor extends BaseModel
|
|||||||
// 'contacts',
|
// 'contacts',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return Vendor::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function documents()
|
public function documents()
|
||||||
{
|
{
|
||||||
return $this->morphMany(Document::class, 'documentable');
|
return $this->morphMany(Document::class, 'documentable');
|
||||||
|
@ -71,6 +71,11 @@ class VendorContact extends Authenticatable implements HasLocalePreference
|
|||||||
'is_primary',
|
'is_primary',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getEntityType()
|
||||||
|
{
|
||||||
|
return VendorContact::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHashedIdAttribute()
|
public function getHashedIdAttribute()
|
||||||
{
|
{
|
||||||
return $this->encodePrimaryKey($this->id);
|
return $this->encodePrimaryKey($this->id);
|
||||||
|
@ -97,7 +97,10 @@ class EntitySentNotification extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject($subject)
|
->subject($subject)
|
||||||
->markdown('email.admin.generic', $data);
|
->markdown('email.admin.generic', $data)
|
||||||
|
->withSwiftMessage(function ($message) {
|
||||||
|
$message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,7 +73,10 @@ class EntityViewedNotification extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject($subject)
|
->subject($subject)
|
||||||
->markdown('email.admin.generic', $data);
|
->markdown('email.admin.generic', $data)
|
||||||
|
->withSwiftMessage(function ($message) {
|
||||||
|
$message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,7 +91,10 @@ class InvoiceSentNotification extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject($subject)
|
->subject($subject)
|
||||||
->markdown('email.admin.generic', $data);
|
->markdown('email.admin.generic', $data)
|
||||||
|
->withSwiftMessage(function ($message) {
|
||||||
|
$message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,7 +89,10 @@ class InvoiceViewedNotification extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject($subject)
|
->subject($subject)
|
||||||
->markdown('email.admin.generic', $data);
|
->markdown('email.admin.generic', $data)
|
||||||
|
->withSwiftMessage(function ($message) {
|
||||||
|
$message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,7 +93,10 @@ class NewPartialPaymentNotification extends Notification implements ShouldQueue
|
|||||||
'texts.notification_partial_payment_paid_subject',
|
'texts.notification_partial_payment_paid_subject',
|
||||||
['client' => $this->payment->client->present()->name()]
|
['client' => $this->payment->client->present()->name()]
|
||||||
)
|
)
|
||||||
)->markdown('email.admin.generic', $data);
|
)->markdown('email.admin.generic', $data)
|
||||||
|
->withSwiftMessage(function ($message) {
|
||||||
|
$message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,7 +96,10 @@ class NewPaymentNotification extends Notification implements ShouldQueue
|
|||||||
'texts.notification_payment_paid_subject',
|
'texts.notification_payment_paid_subject',
|
||||||
['client' => $this->payment->client->present()->name(),]
|
['client' => $this->payment->client->present()->name(),]
|
||||||
)
|
)
|
||||||
)->markdown('email.admin.generic', $data);
|
)->markdown('email.admin.generic', $data)
|
||||||
|
->withSwiftMessage(function ($message) {
|
||||||
|
$message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +88,9 @@ class BaseNotification extends Notification implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $mail_message;
|
return $mail_message->withSwiftMessage(function ($message) {
|
||||||
|
$message->getHeaders()->addTextHeader('Tag', $this->invitation->company->company_key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildMailMessageData() :array
|
public function buildMailMessageData() :array
|
||||||
|
@ -70,6 +70,9 @@ class NewAccountCreated extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject(ctrans('texts.new_signup'))
|
->subject(ctrans('texts.new_signup'))
|
||||||
|
->withSwiftMessage(function ($message) {
|
||||||
|
$message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
|
||||||
|
})
|
||||||
->markdown('email.admin.generic', $data);
|
->markdown('email.admin.generic', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,10 @@ class NewAccountCreated extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject(ctrans('texts.new_signup'))
|
->subject(ctrans('texts.new_signup'))
|
||||||
->markdown('email.admin.generic', $data);
|
->markdown('email.admin.generic', $data)
|
||||||
|
->withSwiftMessage(function ($message) {
|
||||||
|
$message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,7 +74,9 @@ class SendGenericNotification extends BaseNotification implements ShouldQueue
|
|||||||
public function toMail($notifiable)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
$mail_message = (new MailMessage)
|
$mail_message = (new MailMessage)
|
||||||
->markdown('email.admin.generic_email', $this->buildMailMessageData());
|
->withSwiftMessage(function ($message) {
|
||||||
|
$message->getHeaders()->addTextHeader('Tag', $this->invitation->company->company_key);
|
||||||
|
})->markdown('email.admin.generic_email', $this->buildMailMessageData());
|
||||||
|
|
||||||
$mail_message = $this->buildMailMessageSettings($mail_message);
|
$mail_message = $this->buildMailMessageSettings($mail_message);
|
||||||
|
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
use App\Events\Client\ClientWasCreated;
|
use App\Events\Client\ClientWasCreated;
|
||||||
|
use App\Jobs\Util\SubscriptionHandler;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\Subscription;
|
||||||
|
|
||||||
class ClientObserver
|
class ClientObserver
|
||||||
{
|
{
|
||||||
@ -25,6 +27,8 @@ class ClientObserver
|
|||||||
public function created(Client $client)
|
public function created(Client $client)
|
||||||
{
|
{
|
||||||
event(new ClientWasCreated($client));
|
event(new ClientWasCreated($client));
|
||||||
|
|
||||||
|
SubscriptionHandler::dispatch(Subscription::EVENT_CREATE_CLIENT, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +39,7 @@ class ClientObserver
|
|||||||
*/
|
*/
|
||||||
public function updated(Client $client)
|
public function updated(Client $client)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_UPDATE_CLIENT, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,7 +50,8 @@ class ClientObserver
|
|||||||
*/
|
*/
|
||||||
public function deleted(Client $client)
|
public function deleted(Client $client)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_DELETE_CLIENT, $client);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
|
use App\Jobs\Util\SubscriptionHandler;
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
|
use App\Models\Subscription;
|
||||||
|
|
||||||
class ExpenseObserver
|
class ExpenseObserver
|
||||||
{
|
{
|
||||||
@ -23,7 +25,7 @@ class ExpenseObserver
|
|||||||
*/
|
*/
|
||||||
public function created(Expense $expense)
|
public function created(Expense $expense)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_CREATE_EXPENSE, $expense);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +36,7 @@ class ExpenseObserver
|
|||||||
*/
|
*/
|
||||||
public function updated(Expense $expense)
|
public function updated(Expense $expense)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_UPDATE_EXPENSE, $expense);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +47,7 @@ class ExpenseObserver
|
|||||||
*/
|
*/
|
||||||
public function deleted(Expense $expense)
|
public function deleted(Expense $expense)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_DELETE_EXPENSE, $expense);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
|
use App\Jobs\Util\SubscriptionHandler;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Subscription;
|
||||||
|
|
||||||
class InvoiceObserver
|
class InvoiceObserver
|
||||||
{
|
{
|
||||||
@ -23,7 +25,7 @@ class InvoiceObserver
|
|||||||
*/
|
*/
|
||||||
public function created(Invoice $invoice)
|
public function created(Invoice $invoice)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_CREATE_INVOICE, $invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +36,7 @@ class InvoiceObserver
|
|||||||
*/
|
*/
|
||||||
public function updated(Invoice $invoice)
|
public function updated(Invoice $invoice)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_UPDATE_INVOICE, $invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +47,7 @@ class InvoiceObserver
|
|||||||
*/
|
*/
|
||||||
public function deleted(Invoice $invoice)
|
public function deleted(Invoice $invoice)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_DELETE_INVOICE, $invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
use App\Events\Payment\PaymentWasCreated;
|
use App\Events\Payment\PaymentWasCreated;
|
||||||
|
use App\Jobs\Util\SubscriptionHandler;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
|
use App\Models\Subscription;
|
||||||
|
|
||||||
class PaymentObserver
|
class PaymentObserver
|
||||||
{
|
{
|
||||||
@ -24,6 +26,7 @@ class PaymentObserver
|
|||||||
*/
|
*/
|
||||||
public function created(Payment $payment)
|
public function created(Payment $payment)
|
||||||
{
|
{
|
||||||
|
SubscriptionHandler::dispatch(Subscription::EVENT_CREATE_PAYMENT, $payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +37,6 @@ class PaymentObserver
|
|||||||
*/
|
*/
|
||||||
public function updated(Payment $payment)
|
public function updated(Payment $payment)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +47,7 @@ class PaymentObserver
|
|||||||
*/
|
*/
|
||||||
public function deleted(Payment $payment)
|
public function deleted(Payment $payment)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_DELETE_PAYMENT, $payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
|
use App\Jobs\Util\SubscriptionHandler;
|
||||||
use App\Models\Quote;
|
use App\Models\Quote;
|
||||||
|
use App\Models\Subscription;
|
||||||
|
|
||||||
class QuoteObserver
|
class QuoteObserver
|
||||||
{
|
{
|
||||||
@ -23,7 +25,7 @@ class QuoteObserver
|
|||||||
*/
|
*/
|
||||||
public function created(Quote $quote)
|
public function created(Quote $quote)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_CREATE_QUOTE, $quote);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +36,7 @@ class QuoteObserver
|
|||||||
*/
|
*/
|
||||||
public function updated(Quote $quote)
|
public function updated(Quote $quote)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_UPDATE_QUOTE, $quote);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +47,7 @@ class QuoteObserver
|
|||||||
*/
|
*/
|
||||||
public function deleted(Quote $quote)
|
public function deleted(Quote $quote)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_DELETE_QUOTE, $quote);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
|
use App\Jobs\Util\SubscriptionHandler;
|
||||||
|
use App\Models\Subscription;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
|
|
||||||
class TaskObserver
|
class TaskObserver
|
||||||
@ -23,7 +25,7 @@ class TaskObserver
|
|||||||
*/
|
*/
|
||||||
public function created(Task $task)
|
public function created(Task $task)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_CREATE_TASK, $task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +36,7 @@ class TaskObserver
|
|||||||
*/
|
*/
|
||||||
public function updated(Task $task)
|
public function updated(Task $task)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_UPDATE_TASK, $task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +47,7 @@ class TaskObserver
|
|||||||
*/
|
*/
|
||||||
public function deleted(Task $task)
|
public function deleted(Task $task)
|
||||||
{
|
{
|
||||||
//
|
SubscriptionHandler::dispatch(Subscription::EVENT_DELETE_TASK, $task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ class CompanyGatewayTransformer extends EntityTransformer
|
|||||||
'show_shipping_address' => (bool)$company_gateway->show_shipping_address,
|
'show_shipping_address' => (bool)$company_gateway->show_shipping_address,
|
||||||
'update_details' => (bool)$company_gateway->update_details,
|
'update_details' => (bool)$company_gateway->update_details,
|
||||||
'config' => (string) $company_gateway->getConfigTransformed(),
|
'config' => (string) $company_gateway->getConfigTransformed(),
|
||||||
'fees_and_limits' => $company_gateway->fees_and_limits ?: '',
|
'fees_and_limits' => $company_gateway->fees_and_limits ?: new \stdClass,
|
||||||
'updated_at' => (int)$company_gateway->updated_at,
|
'updated_at' => (int)$company_gateway->updated_at,
|
||||||
'archived_at' => (int)$company_gateway->deleted_at,
|
'archived_at' => (int)$company_gateway->deleted_at,
|
||||||
'created_at' => (int)$company_gateway->created_at,
|
'created_at' => (int)$company_gateway->created_at,
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
"fideloper/proxy": "^4.0",
|
"fideloper/proxy": "^4.0",
|
||||||
"fzaninotto/faker": "^1.4",
|
"fzaninotto/faker": "^1.4",
|
||||||
"google/apiclient": "^2.0",
|
"google/apiclient": "^2.0",
|
||||||
|
"guzzlehttp/guzzle": "^6.5",
|
||||||
"hashids/hashids": "^3.0",
|
"hashids/hashids": "^3.0",
|
||||||
"intervention/image": "^2.4",
|
"intervention/image": "^2.4",
|
||||||
"laracasts/presenter": "^0.2.1",
|
"laracasts/presenter": "^0.2.1",
|
||||||
|
@ -31,6 +31,9 @@ class AddIsDeletedColumnToCompanyTokensTable extends Migration
|
|||||||
$table->softDeletes('deleted_at', 6);
|
$table->softDeletes('deleted_at', 6);
|
||||||
|
|
||||||
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
||||||
|
|
||||||
|
$table->index(['event_id', 'company_id']);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::table('companies', function (Blueprint $table) {
|
Schema::table('companies', function (Blueprint $table) {
|
||||||
|
56
tests/Unit/EntityTest.php
Normal file
56
tests/Unit/EntityTest.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit;
|
||||||
|
|
||||||
|
use App\Factory\InvoiceFactory;
|
||||||
|
use App\Factory\InvoiceItemFactory;
|
||||||
|
use App\Helpers\Invoice\InvoiceSum;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Tests\MockAccountData;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
class EntityTest extends TestCase
|
||||||
|
{
|
||||||
|
use MockAccountData;
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
public $invoice;
|
||||||
|
|
||||||
|
public $invoice_calc;
|
||||||
|
|
||||||
|
public $settings;
|
||||||
|
|
||||||
|
public function setUp() :void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->makeTestData();
|
||||||
|
|
||||||
|
$this->invoice->line_items = $this->buildLineItems();
|
||||||
|
|
||||||
|
$this->invoice_calc = new InvoiceSum($this->invoice);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testEntityNameResolution()
|
||||||
|
{
|
||||||
|
|
||||||
|
$entity_type = $this->invoice->getEntityType();
|
||||||
|
|
||||||
|
$this->assertEquals('Invoice', class_basename($entity_type));
|
||||||
|
|
||||||
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
|
$entity_type = $invitation->getEntityType();
|
||||||
|
|
||||||
|
$this->assertEquals('InvoiceInvitation', class_basename($entity_type));
|
||||||
|
|
||||||
|
$this->assertEquals('InvoiceInvitation', class_basename($invitation));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user