Add "both" mode to referrals

Add "both" mode to referrals
This commit is contained in:
Dennis 2022-06-07 16:05:27 +02:00 committed by GitHub
commit afd23f7e72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View file

@ -185,7 +185,7 @@ class PaymentController extends Controller
if ($user->role == 'member') {
$user->update(['role' => 'client']);
if(config("SETTINGS::REFERRAL:MODE") == "commission" && $shopProduct->type=="Credits"){
if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE" == "both")) && $shopProduct->type=="Credits"){
if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){
$ref_user = User::findOrFail($ref_user->referral_id);
$increment = number_format($shopProduct->quantity/100*config("SETTINGS::REFERRAL:PERCENTAGE"),0,"","");
@ -342,7 +342,7 @@ class PaymentController extends Controller
if ($user->role == 'member') {
$user->update(['role' => 'client']);
if(config("SETTINGS::REFERRAL:MODE") == "commission" && $shopProduct->type=="Credits"){
if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE" == "both")) && $shopProduct->type=="Credits"){
if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){
$ref_user = User::findOrFail($ref_user->referral_id);
$increment = number_format($shopProduct->quantity/100*config("SETTINGS::REFERRAL:PERCENTAGE"),0,"","");
@ -457,7 +457,7 @@ class PaymentController extends Controller
if ($user->role == 'member') {
$user->update(['role' => 'client']);
if(config("SETTINGS::REFERRAL:MODE") == "commission" && $shopProduct->type=="Credits"){
if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE" == "both"))&& $shopProduct->type=="Credits"){
if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){
$ref_user = User::findOrFail($ref_user->referral_id);
$increment = number_format($shopProduct->quantity/100*config("SETTINGS::REFERRAL:PERCENTAGE"),0,"","");

View file

@ -139,7 +139,7 @@ class RegisterController extends Controller
$ref_code = $data['referral_code'];
$new_user = $user->id;
if($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) {
if(config("SETTINGS::REFERRAL:MODE" == "sign-up")) {
if(config("SETTINGS::REFERRAL:MODE" == "sign-up") || config("SETTINGS::REFERRAL:MODE" == "both")) {
$ref_user->increment('credits', config("SETTINGS::REFERRAL::REWARD"));
$ref_user->notify(new ReferralNotification($ref_user->id, $new_user));
}

View file

@ -213,6 +213,8 @@
@endif>{{ __("Commission") }}</option>
<option value="sign-up" @if (config('SETTINGS::REFERRAL:MODE') == "sign-up") selected
@endif>{{ __("Sign-Up") }}</option>
<option value="both" @if (config('SETTINGS::REFERRAL:MODE') == "both") selected
@endif>{{ __("Both") }}</option>
</select>
</div>
<div class="form-group mb-3">