diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index 870aeeb30589..66c3fa08e2bb 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -132,22 +132,20 @@ class BaseController extends Controller protected function refreshResponse($query) { + $includes = [ - 'company.tax_rates', + 'company', 'company.groups', 'company.company_gateways.gateway', 'company.clients.contacts', 'company.products', - 'company.invoices.invitations.contact', - 'company.invoices.invitations.company', + 'company.invoices.invitations', 'company.invoices.documents', 'company.payments.paymentables', 'company.quotes.invitations.contact', - 'company.quotes.invitations.company', - 'company.quotes.documents', + 'company.quotes.documents.company', 'company.credits.invitations.contact', - 'company.credits.invitations.company', - 'company.credits.documents', + 'company.credits.documents.company', 'company.payment_terms.company', 'company.credits.invitations.contact', 'company.credits.invitations.company', @@ -156,8 +154,6 @@ class BaseController extends Controller 'company.tasks', 'company.projects', 'company.designs', - 'company.webhooks', - 'company.tokens_hashed' ]; $this->manager->parseIncludes($includes); @@ -170,7 +166,7 @@ class BaseController extends Controller $this->manager->setSerializer(new ArraySerializer()); } - $transformer = new $this->entity_transformer(Input::get('serializer')); + $transformer = new $this->entity_transformer($this->serializer); $updated_at = request()->has('updated_at') ? request()->input('updated_at') : 0; $updated_at = date('Y-m-d H:i:s', $updated_at); @@ -178,7 +174,7 @@ class BaseController extends Controller $query->with( [ 'company' => function ($query) use($updated_at){ - $query->where('updated_at', '>=', date('Y-m-d H:i:s', 0)); + $query->whereNotNull('updated_at'); }, 'company.clients'=>function ($query) use($updated_at){ $query->where('clients.updated_at', '>=', $updated_at)->with('contacts'); @@ -196,7 +192,7 @@ class BaseController extends Controller $query->where('updated_at', '>=', $updated_at); }, 'company.invoices'=>function ($query) use($updated_at){ - $query->where('updated_at', '>=', $updated_at)->with('invitations','documents'); + $query->where('updated_at', '>=', $updated_at)->with('invitations','company','documents'); }, 'company.payments'=>function ($query) use($updated_at){ $query->where('updated_at', '>=', $updated_at)->with('paymentables'); diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index e7db6b4bff98..c4092152c1f3 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -51,7 +51,7 @@ class QueryLogging Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); // if($count > 700) - // Log::info($queries); + Log::info($queries); } } diff --git a/app/Models/Credit.php b/app/Models/Credit.php index 137bb861ff24..70691cbd780b 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -137,6 +137,11 @@ class Credit extends BaseModel return $this->belongsTo(Client::class)->withTrashed(); } + // public function contacts() + // { + // return $this->hasManyThrough(ClientContact::class, Client::class); + // } + public function invitations() { return $this->hasMany(CreditInvitation::class); diff --git a/app/Models/CreditInvitation.php b/app/Models/CreditInvitation.php index 4cb800289b70..cc8ca06288ca 100644 --- a/app/Models/CreditInvitation.php +++ b/app/Models/CreditInvitation.php @@ -34,7 +34,8 @@ class CreditInvitation extends BaseModel ]; protected $with = [ - // 'company', + 'company', + 'contact', ]; protected $touches = ['credit']; diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index fe8ba22a5ec9..4006e4a1f868 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -192,6 +192,11 @@ class Invoice extends BaseModel return $this->belongsTo(Client::class)->withTrashed(); } + // public function contacts() + // { + // return $this->hasManyThrough(ClientContact::class, Client::class); + // } + public function documents() { return $this->morphMany(Document::class, 'documentable'); diff --git a/app/Models/InvoiceInvitation.php b/app/Models/InvoiceInvitation.php index f6fa671ff5ba..86b1fe5c1ed1 100644 --- a/app/Models/InvoiceInvitation.php +++ b/app/Models/InvoiceInvitation.php @@ -33,7 +33,8 @@ class InvoiceInvitation extends BaseModel ]; protected $with = [ - // 'company', + 'company', + 'contact', ]; protected $touches = ['invoice']; diff --git a/app/Models/Quote.php b/app/Models/Quote.php index 98625394b352..df0035c1bae5 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -137,6 +137,11 @@ class Quote extends BaseModel return $this->belongsTo(Client::class)->withTrashed(); } + // public function contacts() + // { + // return $this->hasManyThrough(ClientContact::class, Client::class); + // } + public function assigned_user() { return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed(); diff --git a/app/Models/QuoteInvitation.php b/app/Models/QuoteInvitation.php index a258d1f9f0c4..361a11009075 100644 --- a/app/Models/QuoteInvitation.php +++ b/app/Models/QuoteInvitation.php @@ -33,6 +33,11 @@ class QuoteInvitation extends BaseModel 'client_contact_id', ]; + protected $with = [ + 'company', + 'contact', + ]; + protected $touches = ['quote']; public function getEntityType()