101 lines
2.2 KiB
PHP
101 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Settings;
|
|
use App\Models\Reduction;
|
|
|
|
class re7Controller extends Controller
|
|
{
|
|
/**
|
|
* index
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('re7');
|
|
}
|
|
|
|
/**
|
|
* teaser
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
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'));
|
|
}
|
|
|
|
/**
|
|
* prizeMail
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function prizeMail()
|
|
{
|
|
return view('front.basic.prize-mail');
|
|
}
|
|
|
|
/**
|
|
* reductionMail
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function reductionMail()
|
|
{
|
|
return view('front.basic.reduction-mail');
|
|
}
|
|
|
|
/**
|
|
* br
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function br()
|
|
{
|
|
$settings = app(Settings::class);
|
|
$coupon = $this->getRandomCoupon($settings);
|
|
$crmCoupon = new Reduction();
|
|
return view('front.basic.reduction', compact('coupon', 'crmCoupon'));
|
|
}
|
|
|
|
/**
|
|
* gain 1
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function gain1()
|
|
{
|
|
return view('front.basic.gain1');
|
|
}
|
|
|
|
/**
|
|
* gain 2
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function gain2()
|
|
{
|
|
return view('front.basic.gain2');
|
|
}
|
|
/**
|
|
* getRandomCoupon
|
|
* @param App\Models\Settings $settings
|
|
* @return string
|
|
*/
|
|
private function getRandomCoupon(Settings $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];
|
|
}
|
|
}
|
|
}
|