Reworked query caching for L5

This commit is contained in:
Hillel Coren 2015-04-08 16:19:17 +03:00
parent bb27ca7178
commit 4750bacd71
9 changed files with 163 additions and 269 deletions

View File

@ -11,6 +11,7 @@ use Utils;
use Validator; use Validator;
use View; use View;
use stdClass; use stdClass;
use Cache;
use App\Models\User; use App\Models\User;
use App\Models\Activity; use App\Models\Activity;
@ -129,30 +130,16 @@ class AccountController extends BaseController
public function showSection($section = ACCOUNT_DETAILS, $subSection = false) public function showSection($section = ACCOUNT_DETAILS, $subSection = false)
{ {
if ($section == ACCOUNT_DETAILS) { if ($section == ACCOUNT_DETAILS) {
/* Update Remember Function
$data = [ $data = [
'account' => Account::with('users')->findOrFail(Auth::user()->account_id), 'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'countries' => Cache::get('countries'),
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'sizes' => Cache::get('sizes'),
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'industries' => Cache::get('industries'),
'timezones' => Timezone::remember(DEFAULT_QUERY_CACHE)->orderBy('location')->get(), 'timezones' => Cache::get('timezones'),
'dateFormats' => DateFormat::remember(DEFAULT_QUERY_CACHE)->get(), 'dateFormats' => Cache::get('dateFormats'),
'datetimeFormats' => DatetimeFormat::remember(DEFAULT_QUERY_CACHE)->get(), 'datetimeFormats' => Cache::get('datetimeFormats'),
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'currencies' => Cache::get('currencies'),
'languages' => Language::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'languages' => Cache::get('languages'),
'showUser' => Auth::user()->id === Auth::user()->account->users()->first()->id,
];
*/
$data = [
'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
'countries' => Country::orderBy('name')->get(),
'sizes' => Size::orderBy('id')->get(),
'industries' => Industry::orderBy('name')->get(),
'timezones' => Timezone::orderBy('location')->get(),
'dateFormats' => DateFormat::get(),
'datetimeFormats' => DatetimeFormat::get(),
'currencies' => Currency::orderBy('name')->get(),
'languages' => Language::orderBy('name')->get(),
'showUser' => Auth::user()->id === Auth::user()->account->users()->first()->id, 'showUser' => Auth::user()->id === Auth::user()->account->users()->first()->id,
]; ];
@ -210,8 +197,6 @@ class AccountController extends BaseController
$invoice->invoice_items = [$invoiceItem]; $invoice->invoice_items = [$invoiceItem];
$data['invoice'] = $invoice; $data['invoice'] = $invoice;
//$data['invoiceDesigns'] = InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache_'.Auth::user()->maxInvoiceDesignId())
// ->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get();
$data['invoiceDesigns'] = InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(); $data['invoiceDesigns'] = InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get();
} else if ($subSection == ACCOUNT_EMAIL_TEMPLATES) { } else if ($subSection == ACCOUNT_EMAIL_TEMPLATES) {
$data['invoiceEmail'] = $account->getEmailTemplate(ENTITY_INVOICE); $data['invoiceEmail'] = $account->getEmailTemplate(ENTITY_INVOICE);
@ -391,7 +376,7 @@ class AccountController extends BaseController
$count = 0; $count = 0;
$hasHeaders = Input::get('header_checkbox'); $hasHeaders = Input::get('header_checkbox');
$countries = Country::remember(DEFAULT_QUERY_CACHE)->get(); $countries = Cache::get('countries');
$countryMap = []; $countryMap = [];
foreach ($countries as $country) { foreach ($countries as $country) {

View File

@ -9,6 +9,7 @@ use Validator;
use Input; use Input;
use Session; use Session;
use Redirect; use Redirect;
use Cache;
use App\Models\Activity; use App\Models\Activity;
use App\Models\Client; use App\Models\Client;
@ -178,23 +179,12 @@ class ClientController extends BaseController
private static function getViewModel() private static function getViewModel()
{ {
/* Remember function no longer works
return [ return [
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'sizes' => Cache::get('sizes'),
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']), 'paymentTerms' => Cache::get('paymentTerms'),
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'industries' => Cache::get('industries'),
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'currencies' => Cache::get('currencies'),
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'countries' => Cache::get('countries'),
'customLabel1' => Auth::user()->account->custom_client_label1,
'customLabel2' => Auth::user()->account->custom_client_label2,
];
*/
return [
'sizes' => Size::orderBy('id')->get(),
'paymentTerms' => PaymentTerm::orderBy('num_days')->get(['name', 'num_days']),
'industries' => Industry::orderBy('name')->get(),
'currencies' => Currency::orderBy('name')->get(),
'countries' => Country::orderBy('name')->get(),
'customLabel1' => Auth::user()->account->custom_client_label1, 'customLabel1' => Auth::user()->account->custom_client_label1,
'customLabel2' => Auth::user()->account->custom_client_label2, 'customLabel2' => Auth::user()->account->custom_client_label2,
]; ];

View File

@ -7,7 +7,7 @@ use Session;
use Utils; use Utils;
use View; use View;
use Validator; use Validator;
zz
use App\Models\Client; use App\Models\Client;
use App\Ninja\Repositories\CreditRepository; use App\Ninja\Repositories\CreditRepository;
@ -84,7 +84,6 @@ class CreditController extends BaseController
'method' => 'POST', 'method' => 'POST',
'url' => 'credits', 'url' => 'credits',
'title' => trans('texts.new_credit'), 'title' => trans('texts.new_credit'),
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
//'invoices' => Invoice::scope()->with('client', 'invoice_status')->orderBy('invoice_number')->get(), //'invoices' => Invoice::scope()->with('client', 'invoice_status')->orderBy('invoice_number')->get(),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), ); 'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
@ -102,7 +101,6 @@ class CreditController extends BaseController
'method' => 'PUT', 'method' => 'PUT',
'url' => 'credits/'.$publicId, 'url' => 'credits/'.$publicId,
'title' => 'Edit Credit', 'title' => 'Edit Credit',
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), ); 'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
return View::make('credit.edit', $data); return View::make('credit.edit', $data);

View File

@ -321,42 +321,16 @@ class InvoiceController extends BaseController
} }
} }
/*
return [ return [
'account' => Auth::user()->account, 'account' => Auth::user()->account,
'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')),
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'countries' => Cache::get('countries'),
'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(),
'taxRates' => TaxRate::scope()->orderBy('name')->get(),
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache_'.Auth::user()->maxInvoiceDesignId())
->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
'frequencies' => array(
1 => 'Weekly',
2 => 'Two weeks',
3 => 'Four weeks',
4 => 'Monthly',
5 => 'Three months',
6 => 'Six months',
7 => 'Annually',
),
'recurringHelp' => $recurringHelp
];
*/
return [
'account' => Auth::user()->account,
'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')),
'countries' => Country::orderBy('name')->get(),
'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(),
'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(),
'currencies' => Cache::get('currencies'), 'currencies' => Cache::get('currencies'),
'sizes' => Size::orderBy('id')->get(), 'sizes' => Cache::get('sizes'),
'paymentTerms' => PaymentTerm::orderBy('num_days')->get(['name', 'num_days']), 'paymentTerms' => Cache::get('paymentTerms'),
'industries' => Industry::orderBy('name')->get(), 'industries' => Cache::get('industries'),
'invoiceDesigns' => InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(), 'invoiceDesigns' => InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
'frequencies' => array( 'frequencies' => array(
1 => 'Weekly', 1 => 'Weekly',
@ -593,7 +567,7 @@ class InvoiceController extends BaseController
'invoice' => $invoice, 'invoice' => $invoice,
'versionsJson' => json_encode($versionsJson), 'versionsJson' => json_encode($versionsJson),
'versionsSelect' => $versionsSelect, 'versionsSelect' => $versionsSelect,
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache_'.Auth::user()->maxInvoiceDesignId())->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(), 'invoiceDesigns' => InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
]; ];
return View::make('invoices.history', $data); return View::make('invoices.history', $data);

View File

@ -10,6 +10,7 @@ use Validator;
use Omnipay; use Omnipay;
use CreditCard; use CreditCard;
use URL; use URL;
use Cache;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Invitation; use App\Models\Invitation;
@ -151,8 +152,7 @@ class PaymentController extends BaseController
'method' => 'POST', 'method' => 'POST',
'url' => "payments", 'url' => "payments",
'title' => trans('texts.new_payment'), 'title' => trans('texts.new_payment'),
//'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'paymentTypes' => Cache::get('paymentTypes'),
'paymentTypes' => PaymentType::orderBy('id')->get(),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), ); 'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
return View::make('payments.edit', $data); return View::make('payments.edit', $data);
@ -172,8 +172,7 @@ class PaymentController extends BaseController
'method' => 'PUT', 'method' => 'PUT',
'url' => 'payments/'.$publicId, 'url' => 'payments/'.$publicId,
'title' => trans('texts.edit_payment'), 'title' => trans('texts.edit_payment'),
//'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'paymentTypes' => Cache::get('paymentTypes'),
'paymentTypes' => PaymentType::orderBy('id')->get(),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), ); 'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
return View::make('payments.edit', $data); return View::make('payments.edit', $data);
@ -368,8 +367,7 @@ class PaymentController extends BaseController
'paymentLibrary' => $paymentLibrary, 'paymentLibrary' => $paymentLibrary,
'gateway' => $gateway, 'gateway' => $gateway,
'acceptedCreditCardTypes' => $acceptedCreditCardTypes, 'acceptedCreditCardTypes' => $acceptedCreditCardTypes,
//'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'countries' => Cache::get('countries'),
'countries' => Country::orderBy('name')->get(),
'currencyId' => $client->currency_id, 'currencyId' => $client->currency_id,
'account' => $client->account 'account' => $client->account
]; ];
@ -418,8 +416,7 @@ class PaymentController extends BaseController
'paymentLibrary' => $paymentLibrary, 'paymentLibrary' => $paymentLibrary,
'gateway' => $gateway, 'gateway' => $gateway,
'acceptedCreditCardTypes' => $acceptedCreditCardTypes, 'acceptedCreditCardTypes' => $acceptedCreditCardTypes,
//'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'countries' => Cache::get('countries'),
'countries' => Country::orderBy('name')->get(),
'currencyId' => 1, 'currencyId' => 1,
'paymentTitle' => $affiliate->payment_title, 'paymentTitle' => $affiliate->payment_title,
'paymentSubtitle' => $affiliate->payment_subtitle, 'paymentSubtitle' => $affiliate->payment_subtitle,

View File

@ -5,6 +5,7 @@ use Input;
use Redirect; use Redirect;
use Utils; use Utils;
use View; use View;
use Cache;
use App\Models\Account; use App\Models\Account;
use App\Models\Client; use App\Models\Client;
@ -139,35 +140,17 @@ class QuoteController extends BaseController
private static function getViewModel() private static function getViewModel()
{ {
/*
return [ return [
'entityType' => ENTITY_QUOTE, 'entityType' => ENTITY_QUOTE,
'account' => Auth::user()->account, 'account' => Auth::user()->account,
'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')),
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'countries' => Cache::get('countries'),
'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(),
'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(),
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'currencies' => Cache::get('currencies'),
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'sizes' => Cache::get('sizes'),
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']), 'paymentTerms' => Cache::get('paymentTerms'),
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'industries' => Cache::get('industries'),
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache_'.Auth::user()->maxInvoiceDesignId())
->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
'invoiceLabels' => Auth::user()->account->getInvoiceLabels()
];
*/
// TODO: Add Remember Cache
return [
'entityType' => ENTITY_QUOTE,
'account' => Auth::user()->account,
'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')),
'countries' => Country::orderBy('name')->get(),
'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(),
'taxRates' => TaxRate::scope()->orderBy('name')->get(),
'currencies' => Currency::orderBy('name')->get(),
'sizes' => Size::orderBy('id')->get(),
'paymentTerms' => PaymentTerm::orderBy('num_days')->get(['name', 'num_days']),
'industries' => Industry::orderBy('name')->get(),
'invoiceDesigns' => InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(), 'invoiceDesigns' => InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
'invoiceLabels' => Auth::user()->account->getInvoiceLabels() 'invoiceLabels' => Auth::user()->account->getInvoiceLabels()
]; ];

View File

@ -1,4 +1,4 @@
<?php namespace App\Http\Middleware; <?php namespace app\Http\Middleware;
use Closure; use Closure;
use Utils; use Utils;
@ -9,12 +9,10 @@ use Redirect;
use Cache; use Cache;
use Session; use Session;
use Event; use Event;
use App\Models\Currency;
use App\Events\UserSettingsChanged; use App\Events\UserSettingsChanged;
class StartupCheck { class StartupCheck
{
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
@ -25,30 +23,45 @@ class StartupCheck {
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
// Ensure all request are over HTTPS in production // Ensure all request are over HTTPS in production
if (App::environment() == ENV_PRODUCTION) if (App::environment() == ENV_PRODUCTION) {
{ if (!Request::secure()) {
if (!Request::secure())
{
return Redirect::secure(Request::getRequestUri()); return Redirect::secure(Request::getRequestUri());
} }
} }
// If the database doens't yet exist we'll skip the rest // If the database doens't yet exist we'll skip the rest
if (!Utils::isNinja() && !Utils::isDatabaseSetup()) if (!Utils::isNinja() && !Utils::isDatabaseSetup()) {
{
return $next($request); return $next($request);
} }
// Check currency data has been cached // Check data has been cached
if (!Cache::has('currencies')) $cachedTables = [
{ 'currencies' => 'App\Models\Currency',
Cache::forever('currencies', Currency::orderBy('name')->get()); 'sizes' => 'App\Models\Size',
'industries' => 'App\Models\Industry',
'timezones' => 'App\Models\Timezone',
'dateFormats' => 'App\Models\DateFormat',
'datetimeFormats' => 'App\Models\DatetimeFormat',
'languages' => 'App\Models\Language',
'paymentTerms' => 'App\Models\PaymentTerm',
'paymentTypes' => 'App\Models\PaymentType',
];
foreach ($cachedTables as $name => $class) {
if (!Cache::has($name)) {
$orderBy = 'id';
if ($name == 'paymentTerms') {
$orderBy = 'num_days';
} elseif (property_exists($class, 'name') && $name != 'paymentTypes') {
$orderBy = 'name';
} }
Cache::forever($name, $class::orderBy($orderBy)->get());
}
}
// check the application is up to date and for any news feed messages // check the application is up to date and for any news feed messages
if (Auth::check()) if (Auth::check()) {
{
$count = Session::get(SESSION_COUNTER, 0); $count = Session::get(SESSION_COUNTER, 0);
Session::put(SESSION_COUNTER, ++$count); Session::put(SESSION_COUNTER, ++$count);
@ -65,7 +78,7 @@ class StartupCheck {
$params = [ $params = [
'user_version' => NINJA_VERSION, 'user_version' => NINJA_VERSION,
'latest_version' => $data->version, 'latest_version' => $data->version,
'releases_link' => link_to(RELEASES_URL, 'Invoice Ninja', ['target' => '_blank']) 'releases_link' => link_to(RELEASES_URL, 'Invoice Ninja', ['target' => '_blank']),
]; ];
Session::put('news_feed_id', NEW_VERSION_AVAILABLE); Session::put('news_feed_id', NEW_VERSION_AVAILABLE);
Session::put('news_feed_message', trans('texts.new_version_available', $params)); Session::put('news_feed_message', trans('texts.new_version_available', $params));
@ -81,51 +94,40 @@ class StartupCheck {
} }
} }
// Check if we're requesting to change the account's language // Check if we're requesting to change the account's language
if (Input::has('lang')) if (Input::has('lang')) {
{
$locale = Input::get('lang'); $locale = Input::get('lang');
App::setLocale($locale); App::setLocale($locale);
Session::set(SESSION_LOCALE, $locale); Session::set(SESSION_LOCALE, $locale);
if (Auth::check()) if (Auth::check()) {
{ if ($language = Language::whereLocale($locale)->first()) {
if ($language = Language::whereLocale($locale)->first())
{
$account = Auth::user()->account; $account = Auth::user()->account;
$account->language_id = $language->id; $account->language_id = $language->id;
$account->save(); $account->save();
} }
} }
} } elseif (Auth::check()) {
else if (Auth::check())
{
$locale = Session::get(SESSION_LOCALE, DEFAULT_LOCALE); $locale = Session::get(SESSION_LOCALE, DEFAULT_LOCALE);
App::setLocale($locale); App::setLocale($locale);
} }
// Make sure the account/user localization settings are in the session // Make sure the account/user localization settings are in the session
if (Auth::check() && !Session::has(SESSION_TIMEZONE)) if (Auth::check() && !Session::has(SESSION_TIMEZONE)) {
{
Event::fire(new UserSettingsChanged()); Event::fire(new UserSettingsChanged());
} }
// Check if the user is claiming a license (ie, additional invoices, white label, etc.) // Check if the user is claiming a license (ie, additional invoices, white label, etc.)
$claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license'); $claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license');
if (!$claimingLicense && Input::has('license_key') && Input::has('product_id')) if (!$claimingLicense && Input::has('license_key') && Input::has('product_id')) {
{
$licenseKey = Input::get('license_key'); $licenseKey = Input::get('license_key');
$productId = Input::get('product_id'); $productId = Input::get('product_id');
$data = trim(file_get_contents((Utils::isNinjaDev() ? 'http://ninja.dev' : NINJA_APP_URL)."/claim_license?license_key={$licenseKey}&product_id={$productId}")); $data = trim(file_get_contents((Utils::isNinjaDev() ? 'http://ninja.dev' : NINJA_APP_URL)."/claim_license?license_key={$licenseKey}&product_id={$productId}"));
if ($productId == PRODUCT_INVOICE_DESIGNS) if ($productId == PRODUCT_INVOICE_DESIGNS) {
{ if ($data = json_decode($data)) {
if ($data = json_decode($data)) foreach ($data as $item) {
{
foreach ($data as $item)
{
$design = new InvoiceDesign(); $design = new InvoiceDesign();
$design->id = $item->id; $design->id = $item->id;
$design->name = $item->name; $design->name = $item->name;
@ -139,11 +141,8 @@ class StartupCheck {
Session::flash('message', trans('texts.bought_designs')); Session::flash('message', trans('texts.bought_designs'));
} }
} } elseif ($productId == PRODUCT_WHITE_LABEL) {
else if ($productId == PRODUCT_WHITE_LABEL) if ($data == 'valid') {
{
if ($data == 'valid')
{
$account = Auth::user()->account; $account = Auth::user()->account;
$account->pro_plan_paid = NINJA_DATE; $account->pro_plan_paid = NINJA_DATE;
$account->save(); $account->save();
@ -155,5 +154,4 @@ class StartupCheck {
return $next($request); return $next($request);
} }
} }

View File

@ -193,7 +193,7 @@ class Account extends Eloquent
public function getLocale() public function getLocale()
{ {
$language = Language::remember(DEFAULT_QUERY_CACHE)->where('id', '=', $this->account->language_id)->first(); $language = Language::where('id', '=', $this->account->language_id)->first();
return $language->locale; return $language->locale;
} }

View File

@ -176,37 +176,6 @@
@yield('content') @yield('content')
</div> </div>
<div class="container">
<div class="footer" style="padding-top: 32px">
@if (false)
<div class="pull-right">
{!! Former::open('user/setTheme')->addClass('themeForm') !!}
<div style="display:none">
{!! Former::text('theme_id') !!}
{!! Former::text('path')->value(Request::url()) !!}
</div>
<div class="btn-group tr-action dropup">
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
Site Theme <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#" onclick="setTheme(0)">Default</a></li>
@foreach (Theme::remember(DEFAULT_QUERY_CACHE)->get() as $theme)
<li><a href="#" onclick="setTheme({{ $theme->id }})">{{ ucwords($theme->name) }}</a></li>
@endforeach
</ul>
</div>
{!! Former::close() !!}
</div>
@endif
<!--
Want something changed? We're {!! link_to('https://github.com/hillelcoren/invoice-ninja', 'open source', array('target'=>'_blank')) !!}, email us at {!! link_to('mailto:contact@invoiceninja.com', 'contact@invoiceninja.com') !!}.
-->
</div>
</div>
@if (!Auth::check() || !Auth::user()->registered) @if (!Auth::check() || !Auth::user()->registered)
<div class="modal fade" id="signUpModal" tabindex="-1" role="dialog" aria-labelledby="signUpModalLabel" aria-hidden="true"> <div class="modal fade" id="signUpModal" tabindex="-1" role="dialog" aria-labelledby="signUpModalLabel" aria-hidden="true">