mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 08:14:44 -04:00
Support canceling pro trial
This commit is contained in:
parent
521f2b5d0e
commit
9fc53c8b13
@ -233,6 +233,7 @@ class AccountController extends BaseController
|
|||||||
$company->plan_expires = date_create()->modify($term == PLAN_TERM_MONTHLY ? '+1 month' : '+1 year')->format('Y-m-d');
|
$company->plan_expires = date_create()->modify($term == PLAN_TERM_MONTHLY ? '+1 month' : '+1 year')->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$company->trial_plan = null;
|
||||||
$company->plan = $plan;
|
$company->plan = $plan;
|
||||||
$company->save();
|
$company->save();
|
||||||
|
|
||||||
@ -1461,22 +1462,6 @@ class AccountController extends BaseController
|
|||||||
return Redirect::to('/settings/'.ACCOUNT_USER_DETAILS)->with('message', trans('texts.confirmation_resent'));
|
return Redirect::to('/settings/'.ACCOUNT_USER_DETAILS)->with('message', trans('texts.confirmation_resent'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $plan
|
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
|
||||||
public function startTrial($plan)
|
|
||||||
{
|
|
||||||
/** @var \App\Models\User $user */
|
|
||||||
$user = Auth::user();
|
|
||||||
|
|
||||||
if ($user->isEligibleForTrial($plan)) {
|
|
||||||
$user->account->startTrial($plan);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Redirect::back()->with('message', trans('texts.trial_success'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $section
|
* @param $section
|
||||||
* @param bool $subSection
|
* @param bool $subSection
|
||||||
|
@ -239,8 +239,6 @@ Route::group([
|
|||||||
Route::resource('users', 'UserController');
|
Route::resource('users', 'UserController');
|
||||||
Route::post('users/bulk', 'UserController@bulk');
|
Route::post('users/bulk', 'UserController@bulk');
|
||||||
Route::get('send_confirmation/{user_id}', 'UserController@sendConfirmation');
|
Route::get('send_confirmation/{user_id}', 'UserController@sendConfirmation');
|
||||||
Route::get('start_trial/{plan}', 'AccountController@startTrial')
|
|
||||||
->where(['plan'=>'pro']);
|
|
||||||
Route::get('/switch_account/{user_id}', 'UserController@switchAccount');
|
Route::get('/switch_account/{user_id}', 'UserController@switchAccount');
|
||||||
Route::get('/unlink_account/{user_account_id}/{user_id}', 'UserController@unlinkAccount');
|
Route::get('/unlink_account/{user_account_id}/{user_id}', 'UserController@unlinkAccount');
|
||||||
Route::get('/manage_companies', 'UserController@manageCompanies');
|
Route::get('/manage_companies', 'UserController@manageCompanies');
|
||||||
|
@ -924,6 +924,10 @@ class Account extends Eloquent
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->company->trial_started && $this->company->trial_started != '0000-00-00') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->company->trial_plan = $plan;
|
$this->company->trial_plan = $plan;
|
||||||
$this->company->trial_started = date_create()->format('Y-m-d');
|
$this->company->trial_started = date_create()->format('Y-m-d');
|
||||||
$this->company->save();
|
$this->company->save();
|
||||||
@ -1159,31 +1163,6 @@ class Account extends Eloquent
|
|||||||
return $plan_details && $plan_details['trial'];
|
return $plan_details && $plan_details['trial'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param null $plan
|
|
||||||
* @return array|bool
|
|
||||||
*/
|
|
||||||
public function isEligibleForTrial($plan = null)
|
|
||||||
{
|
|
||||||
if (!$this->company->trial_plan) {
|
|
||||||
if ($plan) {
|
|
||||||
return $plan == PLAN_PRO || $plan == PLAN_ENTERPRISE;
|
|
||||||
} else {
|
|
||||||
return [PLAN_PRO, PLAN_ENTERPRISE];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->company->trial_plan == PLAN_PRO) {
|
|
||||||
if ($plan) {
|
|
||||||
return $plan != PLAN_PRO;
|
|
||||||
} else {
|
|
||||||
return [PLAN_ENTERPRISE];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@ -138,15 +138,6 @@ class User extends Authenticatable
|
|||||||
return $this->account->isTrial();
|
return $this->account->isTrial();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param null $plan
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function isEligibleForTrial($plan = null)
|
|
||||||
{
|
|
||||||
return $this->account->isEligibleForTrial($plan);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user