From b7f09685d06c70098dbda312c9ae14f5476d0d4b Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sat, 7 Dec 2013 22:33:07 +0200 Subject: [PATCH] Cleaning up the routes.php file --- .gitignore | 1 + app/config/app.php | 2 +- app/controllers/AccountController.php | 12 +- app/controllers/ActivityController.php | 2 +- app/controllers/ClientController.php | 12 +- app/controllers/CreditController.php | 6 +- app/controllers/InvoiceController.php | 12 +- app/controllers/PaymentController.php | 6 +- app/controllers/UserController.php | 11 +- app/libraries/utils.php | 152 +++++++++++++++++++++ app/models/Client.php | 2 +- app/models/Contact.php | 2 +- app/models/User.php | 2 +- app/routes.php | 155 +--------------------- app/views/accounts/settings.blade.php | 4 +- app/views/clients/show.blade.php | 2 +- app/views/header.blade.php | 2 +- app/views/invoices/edit.blade.php | 6 +- app/views/users/forgot_password.blade.php | 76 +++++++++++ app/views/users/login.blade.php | 42 ++---- bootstrap/start.php | 1 + composer.json | 3 +- public/js/bootstrap-combobox.js | 1 + 23 files changed, 292 insertions(+), 222 deletions(-) create mode 100755 app/libraries/utils.php diff --git a/.gitignore b/.gitignore index e0d0d37db7..4f688793b4 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/app/config/staging /bootstrap/compiled.php /vendor composer.phar diff --git a/app/config/app.php b/app/config/app.php index 90d2aeec0f..962dd37a46 100755 --- a/app/config/app.php +++ b/app/config/app.php @@ -65,7 +65,7 @@ return array( | */ - 'key' => 'Zwa83ZM8ZYjEAfHWXl7SvYwVdV9X*oU1', + 'key' => 'a2jfy6HtBEdNtJnRSOC7vIM3UVhxZ1BB', /* |-------------------------------------------------------------------------- diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index b5be1a7548..ba3006cc5a 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -4,8 +4,12 @@ class AccountController extends \BaseController { public function getStarted() { - $user = false; + if (Auth::check()) + { + return Redirect::to('invoices/create'); + } + $user = false; $guestKey = Input::get('guest_key'); if ($guestKey) @@ -128,7 +132,7 @@ class AccountController extends \BaseController { $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, toArray($contacts)); + AccountController::exportData($output, Utils::toArray($contacts)); $invoices = Invoice::where('account_id','=',Auth::user()->account_id)->get(); AccountController::exportData($output, $invoices->toArray()); @@ -136,7 +140,7 @@ class AccountController extends \BaseController { $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, toArray($invoiceItems)); + AccountController::exportData($output, Utils::toArray($invoiceItems)); $payments = Payment::where('account_id','=',Auth::user()->account_id)->get(); AccountController::exportData($output, $payments->toArray()); @@ -251,7 +255,7 @@ class AccountController extends \BaseController { $client->contacts()->save($contact); } - $message = pluralize('Successfully created ? client', $count); + $message = Utils::pluralize('Successfully created ? client', $count); Session::flash('message', $message); return Redirect::to('clients'); } diff --git a/app/controllers/ActivityController.php b/app/controllers/ActivityController.php index 72daee516e..04713f2106 100755 --- a/app/controllers/ActivityController.php +++ b/app/controllers/ActivityController.php @@ -7,7 +7,7 @@ class ActivityController extends \BaseController { $clientId = Client::getPrivateId($clientPublicId); return Datatable::collection(Activity::scope()->where('client_id','=',$clientId)->get()) - ->addColumn('date', function($model) { return timestampToDateString($model->created_at); }) + ->addColumn('date', function($model) { return Utils::timestampToDateString($model->created_at); }) ->addColumn('message', function($model) { return $model->message; }) ->addColumn('balance', function($model) { return '$' . $model->balance; }) ->orderColumns('date') diff --git a/app/controllers/ClientController.php b/app/controllers/ClientController.php index 7cbab2cb45..5473ee8a53 100755 --- a/app/controllers/ClientController.php +++ b/app/controllers/ClientController.php @@ -26,17 +26,17 @@ class ClientController extends \BaseController { ->where('clients.account_id', '=', Auth::user()->account_id) ->where('clients.deleted_at', '=', null) ->where('contacts.is_primary', '=', true) - ->select('clients.public_id','clients.name','contacts.first_name','contacts.last_name','clients.balance','clients.last_login','clients.created_at','contacts.phone','contacts.email'); + ->select('clients.public_id','clients.name','contacts.first_name','contacts.last_name','clients.balance','clients.last_login','clients.created_at','clients.work_phone','contacts.email'); return Datatable::query($query) ->addColumn('checkbox', function($model) { return ''; }) ->addColumn('name', function($model) { return link_to('clients/' . $model->public_id, $model->name); }) ->addColumn('first_name', function($model) { return $model->first_name . ' ' . $model->last_name; }) ->addColumn('balance', function($model) { return '$' . $model->balance; }) - ->addColumn('last_login', function($model) { return timestampToDateString($model->last_login); }) - ->addColumn('created_at', function($model) { return timestampToDateString($model->created_at); }) + ->addColumn('last_login', function($model) { return Utils::timestampToDateString($model->last_login); }) + ->addColumn('created_at', function($model) { return Utils::timestampToDateString($model->created_at); }) ->addColumn('email', function($model) { return $model->email ? HTML::mailto($model->email, $model->email) : ''; }) - ->addColumn('phone', function($model) { return $model->phone; }) + ->addColumn('work_phone', function($model) { return Utils::formatPhoneNumber($model->work_phone); }) ->addColumn('dropdown', function($model) { return '