public function cancelAccount()
{
if ($reason = trim(Input::get('reason'))) {
$email = Auth::user()->email;
$name = Auth::user()->getDisplayName();
$data = ['text' => $reason];
$subject = 'Invoice Ninja - Canceled Account';
$this->userMailer->sendTo(CONTACT_EMAIL, $email, $name, $subject, 'contact', $data);
}
$user = Auth::user();
$account = Auth::user()->account;
\Log::info("Canceled Account: {$account->name} - {$user->email}");
Document::scope()->each(function ($item, $key) {
$item->delete();
});
$this->accountRepo->unlinkAccount($account);
if ($account->company->accounts->count() == 1) {
$account->company->forceDelete();
} else {
$account->forceDelete();
}
Auth::logout();
Session::flush();
return Redirect::to('/')->with('clearGuestKey', true);
}