diff --git a/app/Http/Controllers/Auth/Users.php b/app/Http/Controllers/Auth/Users.php index 0c16e6941..5f62ae6dd 100644 --- a/app/Http/Controllers/Auth/Users.php +++ b/app/Http/Controllers/Auth/Users.php @@ -23,7 +23,7 @@ class Users extends Controller */ public function index() { - $users = User::with('roles')->collect(); + $users = User::with(['media', 'roles'])->collect(); return view('auth.users.index', compact('users')); } diff --git a/app/Http/Controllers/Common/Items.php b/app/Http/Controllers/Common/Items.php index b08400940..e435526f8 100644 --- a/app/Http/Controllers/Common/Items.php +++ b/app/Http/Controllers/Common/Items.php @@ -28,7 +28,7 @@ class Items extends Controller */ public function index() { - $items = Item::with('category')->collect(); + $items = Item::with(['category', 'media'])->collect(); return view('common.items.index', compact('items')); } diff --git a/app/Http/Controllers/Purchases/Bills.php b/app/Http/Controllers/Purchases/Bills.php index 8683c7f6d..3e73b2905 100644 --- a/app/Http/Controllers/Purchases/Bills.php +++ b/app/Http/Controllers/Purchases/Bills.php @@ -37,7 +37,7 @@ class Bills extends Controller */ public function index() { - $bills = Bill::with('contact')->collect(['billed_at'=> 'desc']); + $bills = Bill::with(['contact', 'transactions'])->collect(['billed_at'=> 'desc']); $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); diff --git a/app/Http/Controllers/Purchases/Payments.php b/app/Http/Controllers/Purchases/Payments.php index 0c8c47783..2f0217788 100644 --- a/app/Http/Controllers/Purchases/Payments.php +++ b/app/Http/Controllers/Purchases/Payments.php @@ -30,7 +30,7 @@ class Payments extends Controller */ public function index() { - $payments = Transaction::with(['account', 'category', 'contact'])->expense()->isNotTransfer()->collect(['paid_at'=> 'desc']); + $payments = Transaction::with(['account', 'bill', 'category', 'contact'])->expense()->isNotTransfer()->collect(['paid_at'=> 'desc']); $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); diff --git a/app/Http/Controllers/Sales/Invoices.php b/app/Http/Controllers/Sales/Invoices.php index 02d84a29e..9a68433fb 100644 --- a/app/Http/Controllers/Sales/Invoices.php +++ b/app/Http/Controllers/Sales/Invoices.php @@ -38,7 +38,7 @@ class Invoices extends Controller */ public function index() { - $invoices = Invoice::with('contact')->collect(['invoice_number'=> 'desc']); + $invoices = Invoice::with(['contact', 'transactions'])->collect(['invoice_number'=> 'desc']); $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); diff --git a/app/Http/Controllers/Sales/Revenues.php b/app/Http/Controllers/Sales/Revenues.php index 3a4b5927b..22986bc99 100644 --- a/app/Http/Controllers/Sales/Revenues.php +++ b/app/Http/Controllers/Sales/Revenues.php @@ -30,7 +30,7 @@ class Revenues extends Controller */ public function index() { - $revenues = Transaction::with(['account', 'category', 'contact'])->income()->isNotTransfer()->collect(['paid_at'=> 'desc']); + $revenues = Transaction::with(['account', 'category', 'contact', 'invoice'])->income()->isNotTransfer()->collect(['paid_at'=> 'desc']); $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); diff --git a/app/Widgets/AccountBalance.php b/app/Widgets/AccountBalance.php index 5318d18aa..cea44d4ef 100644 --- a/app/Widgets/AccountBalance.php +++ b/app/Widgets/AccountBalance.php @@ -11,7 +11,7 @@ class AccountBalance extends Widget public function show() { - $accounts = Account::enabled()->take(5)->get(); + $accounts = Account::with(['income_transactions', 'expense_transactions'])->enabled()->take(5)->get(); return $this->view('widgets.account_balance', [ 'accounts' => $accounts, diff --git a/app/Widgets/TotalExpenses.php b/app/Widgets/TotalExpenses.php index 90787c309..06617aa09 100644 --- a/app/Widgets/TotalExpenses.php +++ b/app/Widgets/TotalExpenses.php @@ -22,7 +22,7 @@ class TotalExpenses extends Widget $current += $transaction->getAmountConvertedToDefault(); }); - $this->applyFilters(Bill::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($bill) use (&$open, &$overdue) { + $this->applyFilters(Bill::with('transactions')->accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($bill) use (&$open, &$overdue) { list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($bill); $open += $open_tmp; diff --git a/app/Widgets/TotalIncome.php b/app/Widgets/TotalIncome.php index 9f8edcef1..e4b5c17b3 100644 --- a/app/Widgets/TotalIncome.php +++ b/app/Widgets/TotalIncome.php @@ -22,7 +22,7 @@ class TotalIncome extends Widget $current += $transaction->getAmountConvertedToDefault(); }); - $this->applyFilters(Invoice::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($invoice) use (&$open, &$overdue) { + $this->applyFilters(Invoice::with('transactions')->accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($invoice) use (&$open, &$overdue) { list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($invoice); $open += $open_tmp; diff --git a/app/Widgets/TotalProfit.php b/app/Widgets/TotalProfit.php index 0e1c37a77..d25b30f0c 100644 --- a/app/Widgets/TotalProfit.php +++ b/app/Widgets/TotalProfit.php @@ -30,14 +30,14 @@ class TotalProfit extends Widget } }); - $this->applyFilters(Invoice::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($invoice) use (&$open_invoice, &$overdue_invoice) { + $this->applyFilters(Invoice::with('transactions')->accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($invoice) use (&$open_invoice, &$overdue_invoice) { list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($invoice); $open_invoice += $open_tmp; $overdue_invoice += $overdue_tmp; }); - $this->applyFilters(Bill::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($bill) use (&$open_bill, &$overdue_bill) { + $this->applyFilters(Bill::with('transactions')->accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($bill) use (&$open_bill, &$overdue_bill) { list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($bill); $open_bill += $open_tmp;