From 6377d2a91b88ea3867f2cc52a108a5bf195168fe Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 31 Mar 2014 13:52:03 +0300 Subject: [PATCH] Bug fixes --- app/controllers/AccountController.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index d9a0fb2829..31d5bc4a4e 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -171,26 +171,22 @@ class AccountController extends \BaseController { header("Content-Type:application/csv"); header("Content-Disposition:attachment;filename=export.csv"); - $clients = Client::where('account_id','=',Auth::user()->account_id)->get(); + $clients = Client::scope()->get(); AccountController::exportData($output, $clients->toArray()); - $contacts = DB::table('contacts')->whereIn('client_id', function($query){ - $query->select('client_id')->from('clients')->where('account_id','=',Auth::user()->account_id); - })->get(); - AccountController::exportData($output, Utils::toArray($contacts)); - - $invoices = Invoice::where('account_id','=',Auth::user()->account_id)->get(); - AccountController::exportData($output, $invoices->toArray()); + $contacts = Contact::scope()->get(); + AccountController::exportData($output, $contacts->toArray()); - $invoiceItems = DB::table('invoice_items')->whereIn('invoice_id', function($query){ - $query->select('invoice_id')->from('invoices')->where('account_id','=',Auth::user()->account_id); - })->get(); - AccountController::exportData($output, Utils::toArray($invoiceItems)); + $invoices = Invoice::scope()->get(); + AccountController::exportData($output, $invoices->toArray()); - $payments = Payment::where('account_id','=',Auth::user()->account_id)->get(); + $invoiceItems = InvoiceItem::scope()->get(); + AccountController::exportData($output, $invoiceItems->toArray()); + + $payments = Payment::scope()->get(); AccountController::exportData($output, $payments->toArray()); - $credits = Credit::where('account_id','=',Auth::user()->account_id)->get(); + $credits = Credit::scope()->get(); AccountController::exportData($output, $credits->toArray()); fclose($output);