diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index 1ec12ef567f0..66c3fa08e2bb 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -133,7 +133,30 @@ class BaseController extends Controller protected function refreshResponse($query) { -// $this->manager->parseIncludes($includes); + $includes = [ + 'company', + 'company.groups', + 'company.company_gateways.gateway', + 'company.clients.contacts', + 'company.products', + 'company.invoices.invitations', + 'company.invoices.documents', + 'company.payments.paymentables', + 'company.quotes.invitations.contact', + 'company.quotes.documents.company', + 'company.credits.invitations.contact', + 'company.credits.documents.company', + 'company.payment_terms.company', + 'company.credits.invitations.contact', + 'company.credits.invitations.company', + 'company.vendors.contacts', + 'company.expenses', + 'company.tasks', + 'company.projects', + 'company.designs', + ]; + + $this->manager->parseIncludes($includes); $this->serializer = request()->input('serializer') ?: EntityTransformer::API_SERIALIZER_ARRAY; @@ -143,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); @@ -169,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'); @@ -422,6 +445,8 @@ class BaseController extends Controller $data['report_errors'] = true; } + $data['hash'] = md5(public_path('main.dart.js')); + return view('index.index', $data); } diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 97d214d595b0..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() diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index e4cd473f4043..5184432fc7cd 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -5,7 +5,7 @@ Invoice Ninja - + @@ -75,7 +75,7 @@ - +