2021-05-27 20:34:09 +02:00
|
|
|
<?php
|
|
|
|
|
|
2023-12-01 11:45:12 +01:00
|
|
|
namespace App\Http\Controllers\Bo;
|
2021-05-27 20:34:09 +02:00
|
|
|
|
2023-11-21 16:24:23 +01:00
|
|
|
use App\Http\Controllers\Controller;
|
2023-12-05 18:41:58 +01:00
|
|
|
use App\Models\Prize;
|
2021-05-27 20:34:09 +02:00
|
|
|
use App\Models\Settings;
|
2022-01-11 12:39:28 +01:00
|
|
|
use App\Models\Reduction;
|
2023-12-01 11:45:12 +01:00
|
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
|
use Illuminate\Http\Request;
|
2021-05-27 20:34:09 +02:00
|
|
|
|
2023-08-24 12:59:51 +00:00
|
|
|
class Re7Controller extends Controller
|
2021-05-27 20:34:09 +02:00
|
|
|
{
|
2022-08-11 10:26:29 +02:00
|
|
|
/**
|
2023-12-01 11:45:12 +01:00
|
|
|
* Re7Controller
|
2023-08-24 12:59:51 +00:00
|
|
|
*
|
2023-12-01 11:45:12 +01:00
|
|
|
* @return void
|
2022-08-11 10:26:29 +02:00
|
|
|
*/
|
2023-12-01 11:45:12 +01:00
|
|
|
public function __construct()
|
2021-05-27 20:34:09 +02:00
|
|
|
{
|
2023-12-01 11:45:12 +01:00
|
|
|
$this->middleware(function (Request $request, \Closure $next) {
|
|
|
|
|
$this->authorize('fo.showRe7');
|
|
|
|
|
return $next($request);
|
|
|
|
|
});
|
2021-05-27 20:34:09 +02:00
|
|
|
}
|
|
|
|
|
|
2023-12-05 12:33:25 +01:00
|
|
|
/**
|
|
|
|
|
* Show Teaser page
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
|
|
|
|
public function teaser(): View
|
|
|
|
|
{
|
|
|
|
|
return view('theme::pages.teaser');
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-05 18:41:58 +01:00
|
|
|
// * -- Participation
|
|
|
|
|
|
2022-08-11 10:26:29 +02:00
|
|
|
/**
|
2023-12-05 18:41:58 +01:00
|
|
|
* Show prize page
|
2023-08-24 12:59:51 +00:00
|
|
|
*
|
2023-12-05 18:41:58 +01:00
|
|
|
* @param \App\Models\Prize $prize
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
2022-08-11 10:26:29 +02:00
|
|
|
*/
|
2023-12-05 18:41:58 +01:00
|
|
|
public function prize(Prize $prize): View
|
2021-05-27 20:34:09 +02:00
|
|
|
{
|
2023-12-05 18:41:58 +01:00
|
|
|
return view('theme::pages.participation.won', [
|
|
|
|
|
'prizeModel' => $prize
|
|
|
|
|
]);
|
2021-05-27 20:34:09 +02:00
|
|
|
}
|
|
|
|
|
|
2022-08-11 10:26:29 +02:00
|
|
|
/**
|
2023-12-05 18:41:58 +01:00
|
|
|
* Show discount page
|
2023-08-24 12:59:51 +00:00
|
|
|
*
|
2023-12-05 18:41:58 +01:00
|
|
|
* @return \Illuminate\Contracts\View\View
|
2022-08-11 10:26:29 +02:00
|
|
|
*/
|
2023-12-05 18:41:58 +01:00
|
|
|
public function br(): View
|
2021-05-27 20:34:09 +02:00
|
|
|
{
|
2023-12-05 18:41:58 +01:00
|
|
|
/** @var \App\Models\Settings */
|
|
|
|
|
$settings = app(Settings::class);
|
|
|
|
|
$coupon = $this->getRandomCoupon($settings);
|
|
|
|
|
$crmCoupon = new Reduction();
|
|
|
|
|
return view('theme::pages.participation.won', compact('coupon', 'crmCoupon'));
|
2021-05-27 20:34:09 +02:00
|
|
|
}
|
|
|
|
|
|
2022-08-11 10:26:29 +02:00
|
|
|
/**
|
2023-12-05 18:41:58 +01:00
|
|
|
* Show loose page
|
2023-08-24 12:59:51 +00:00
|
|
|
*
|
2023-12-05 18:41:58 +01:00
|
|
|
* @return \Illuminate\Contracts\View\View
|
2022-08-11 10:26:29 +02:00
|
|
|
*/
|
2023-12-05 18:41:58 +01:00
|
|
|
public function loose(): View
|
2021-05-27 20:34:09 +02:00
|
|
|
{
|
2023-12-05 18:41:58 +01:00
|
|
|
return view('theme::pages.participation.loose');
|
2021-05-27 20:34:09 +02:00
|
|
|
}
|
|
|
|
|
|
2023-12-05 18:41:58 +01:00
|
|
|
// * -- END Participation
|
|
|
|
|
|
2022-08-11 10:26:29 +02:00
|
|
|
/**
|
2023-12-05 18:41:58 +01:00
|
|
|
* prizeMail
|
2023-08-24 12:59:51 +00:00
|
|
|
*
|
2022-08-11 10:26:29 +02:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
|
*/
|
2023-12-05 18:41:58 +01:00
|
|
|
public function prizeMail()
|
2021-05-27 20:34:09 +02:00
|
|
|
{
|
2023-12-05 18:41:58 +01:00
|
|
|
return view('theme::prize-mail');
|
2021-05-27 20:34:09 +02:00
|
|
|
}
|
|
|
|
|
|
2022-08-11 10:26:29 +02:00
|
|
|
/**
|
2023-12-05 18:41:58 +01:00
|
|
|
* reductionMail
|
2023-08-24 12:59:51 +00:00
|
|
|
*
|
2022-08-11 10:26:29 +02:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
|
*/
|
2023-12-05 18:41:58 +01:00
|
|
|
public function reductionMail()
|
2021-05-27 20:34:09 +02:00
|
|
|
{
|
2023-12-05 18:41:58 +01:00
|
|
|
return view('theme::reduction-mail');
|
2021-05-27 20:34:09 +02:00
|
|
|
}
|
2023-12-05 18:41:58 +01:00
|
|
|
|
2022-08-11 10:26:29 +02:00
|
|
|
/**
|
|
|
|
|
* getRandomCoupon
|
2023-08-24 12:59:51 +00:00
|
|
|
*
|
2022-08-11 10:26:29 +02:00
|
|
|
* @param App\Models\Settings $settings
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
private function getRandomCoupon(Settings $settings)
|
2021-08-18 17:08:02 +02:00
|
|
|
{
|
2021-07-13 17:29:30 +02:00
|
|
|
$webCoupons = json_decode($settings->web_coupons);
|
|
|
|
|
if (count($webCoupons) > 1) {
|
|
|
|
|
$lots = [];
|
2021-08-18 17:08:02 +02:00
|
|
|
foreach ($webCoupons as $webCoupon) {
|
2021-07-13 17:29:30 +02:00
|
|
|
$lots[] = $webCoupon;
|
2021-08-18 17:08:02 +02:00
|
|
|
}
|
|
|
|
|
foreach ($lots as $lot) {
|
|
|
|
|
for ($i = 0; $i < $lot->percentage; $i++) {
|
2021-07-13 17:29:30 +02:00
|
|
|
$tmp[] = $lot;
|
2021-08-18 17:08:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-07-13 17:29:30 +02:00
|
|
|
shuffle($tmp);
|
|
|
|
|
return $tmp[0];
|
|
|
|
|
} else {
|
|
|
|
|
return $webCoupons[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-27 20:34:09 +02:00
|
|
|
}
|