- add code parameters into config - add code length parameter into settings - add total possible codes to generate in generation page - add GenerateRequest validation - changed job ProcessUniqueCode to increase performances using mass insert and pagination - changed singletoned Settings instance to increase performances - Fix process export code put datetime in file name - aded storage to gitignore file - fixed export to guess export codes, also non recursive now - changed refactorize a bit EnterCodeController::participate + add request - Add request to export and generate codes requests
69 lines
1.6 KiB
PHP
69 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Settings;
|
|
use App\Models\Reductions;
|
|
|
|
class re7Controller extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
return view('re7');
|
|
}
|
|
|
|
public function teaser()
|
|
{
|
|
$settings = app(Settings::class)->select('start_date', 'end_date', 'activated_teaser', 'teaser_end_activity')->first();
|
|
return view('front.basic.teaser', compact('settings'));
|
|
}
|
|
|
|
public function prizeMail()
|
|
{
|
|
return view('front.basic.prize-mail');
|
|
}
|
|
|
|
public function reductionMail()
|
|
{
|
|
return view('front.basic.reduction-mail');
|
|
}
|
|
|
|
public function br()
|
|
{
|
|
$settings = app(Settings::class);
|
|
$coupon = $this->getRandomCoupon($settings);
|
|
$crmCoupon = new Reductions();
|
|
return view('front.basic.reduction', compact('coupon', 'crmCoupon'));
|
|
}
|
|
|
|
public function gain1()
|
|
{
|
|
return view('front.basic.gain1');
|
|
}
|
|
|
|
public function gain2()
|
|
{
|
|
return view('front.basic.gain2');
|
|
}
|
|
|
|
|
|
private function getRandomCoupon($settings)
|
|
{
|
|
$webCoupons = json_decode($settings->web_coupons);
|
|
if (count($webCoupons) > 1) {
|
|
$lots = [];
|
|
foreach ($webCoupons as $webCoupon) {
|
|
$lots[] = $webCoupon;
|
|
}
|
|
foreach ($lots as $lot) {
|
|
for ($i = 0; $i < $lot->percentage; $i++) {
|
|
$tmp[] = $lot;
|
|
}
|
|
}
|
|
shuffle($tmp);
|
|
return $tmp[0];
|
|
} else {
|
|
return $webCoupons[0];
|
|
}
|
|
}
|
|
}
|