33 lines
No EOL
832 B
PHP
33 lines
No EOL
832 B
PHP
<?php
|
|
namespace App\Services;
|
|
|
|
|
|
use App\User;
|
|
use App\Models\PromotionUser;
|
|
|
|
class UserService
|
|
{
|
|
public static function createConfirmationCode() {
|
|
$unique = false;
|
|
do{
|
|
$confirmation_code = str_random(30);
|
|
if(User::where('confirmation_code', '=', $confirmation_code)->count() == 0){
|
|
$unique = true;
|
|
}
|
|
}
|
|
while(!$unique);
|
|
return $confirmation_code;
|
|
}
|
|
|
|
|
|
|
|
public static function hasActivePromotion($user) {
|
|
$promotion_users = PromotionUser::where('user_id', $user->id)->where('active', 1)->whereNull('user_deleted_at')->get();
|
|
foreach($promotion_users as $promotion_user){
|
|
if($promotion_user->promotion_admin->isActive()){
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
} |