Merge branch 'develop' into trunk
This commit is contained in:
commit
bf8a70f47b
105 changed files with 8971 additions and 590 deletions
|
|
@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Hash;
|
|||
|
||||
class CreateAdmin extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
|
|
@ -39,25 +40,25 @@ class CreateAdmin extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
$firstname = $this->ask('What is the firstname?','Informatique');
|
||||
$lastname = $this->ask('What is the lastname?','Internet');
|
||||
$email = $this->ask('What is the email?', 'informatique.internet@ldc.fr');
|
||||
$pwd = $this->secret('What is the password?');
|
||||
$role = $this->ask('Role ?','1');
|
||||
$firstname = $this->ask('What is the firstname?', 'Informatique');
|
||||
$lastname = $this->ask('What is the lastname?', 'Internet');
|
||||
$email = $this->ask('What is the email?', 'informatique.internet@ldc.fr');
|
||||
$pwd = $this->secret('What is the password?');
|
||||
$role = $this->ask('Role ?', '1');
|
||||
|
||||
$user = new User();
|
||||
$user->firstname = $firstname;
|
||||
$user->lastname = $lastname;
|
||||
$user->birth_date = now();
|
||||
$user->email = $email;
|
||||
$user->password = Hash::make($pwd);
|
||||
$user->address = "-";
|
||||
$user->town = "Le Mans";
|
||||
$user->postal_code = "72000";
|
||||
$user->country = "France";
|
||||
$user = new User();
|
||||
$user->firstname = $firstname;
|
||||
$user->lastname = $lastname;
|
||||
$user->birth_date = now();
|
||||
$user->email = $email;
|
||||
$user->password = Hash::make($pwd);
|
||||
$user->address = "-";
|
||||
$user->town = "Le Mans";
|
||||
$user->postal_code = "72000";
|
||||
$user->country = "France";
|
||||
$user->email_verify_token = "-";
|
||||
$user->email_verified = 1;
|
||||
$user->role = $role;
|
||||
$user->email_verified = 1;
|
||||
$user->role = $role;
|
||||
$user->save();
|
||||
|
||||
$this->info('User created.');
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use Illuminate\Console\Command;
|
|||
|
||||
class DeleteNotConfirmedUser extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
|
|
@ -40,7 +41,8 @@ class DeleteNotConfirmedUser extends Command
|
|||
public function handle()
|
||||
{
|
||||
$users = User::where([['email_verified', 0], ['created_at', '<', Carbon::now()->subDay()]])->get();
|
||||
foreach ($users as $user)
|
||||
foreach ($users as $user) {
|
||||
$user->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Mail;
|
|||
|
||||
class ExportCodesUniques extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
|
|
@ -62,10 +63,10 @@ class ExportCodesUniques extends Command
|
|||
}
|
||||
$nbCodeLigne = intval($nbCodeLigne);
|
||||
|
||||
$totalExportedCodes = 0;
|
||||
$currentFilename = 1;
|
||||
$totalExportedCodes = 0;
|
||||
$currentFilename = 1;
|
||||
$currentExportedCodes = 0;
|
||||
$currentLineCodes = ($nbCodeLigne === 1 ? 1 : 0);
|
||||
$currentLineCodes = ($nbCodeLigne === 1 ? 1 : 0);
|
||||
|
||||
$this->info("Traitement en cours, veuillez patienter...");
|
||||
|
||||
|
|
@ -75,11 +76,13 @@ class ExportCodesUniques extends Command
|
|||
|
||||
// Compression des fichiers
|
||||
$zip = new \ZipArchive();
|
||||
if ($zip->open(storage_path('export_codes_uniques/') . "CodesUniques_". date('dmY') .".zip",\ZipArchive::CREATE)===TRUE) {
|
||||
if ($zip->open(storage_path('export_codes_uniques/') . "CodesUniques_" . date('dmY') . ".zip", \ZipArchive::CREATE) === true) {
|
||||
if ($handle = opendir(storage_path('export_codes_uniques/tmp'))) {
|
||||
while (false !== ($file_to_zip = readdir($handle))) {
|
||||
if (pathinfo($file_to_zip,PATHINFO_EXTENSION)!='csv') continue;
|
||||
$zip->addFile(storage_path('export_codes_uniques/tmp/') . $file_to_zip,"$file_to_zip");
|
||||
if (pathinfo($file_to_zip, PATHINFO_EXTENSION) != 'csv') {
|
||||
continue;
|
||||
}
|
||||
$zip->addFile(storage_path('export_codes_uniques/tmp/') . $file_to_zip, "$file_to_zip");
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
|
@ -89,34 +92,37 @@ class ExportCodesUniques extends Command
|
|||
// On vide le dossier temporaire des fichiers csv
|
||||
if ($handle = opendir(storage_path('export_codes_uniques/tmp'))) {
|
||||
while (false !== ($file_to_zip = readdir($handle))) {
|
||||
if (pathinfo($file_to_zip,PATHINFO_EXTENSION)!='csv') continue;
|
||||
if (pathinfo($file_to_zip, PATHINFO_EXTENSION) != 'csv') {
|
||||
continue;
|
||||
}
|
||||
unlink(storage_path('export_codes_uniques/tmp/') . $file_to_zip);
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
$this->info("L'archive CodesUniques_". date('dmY') .".zip a ete creer.");
|
||||
$this->info("L'archive CodesUniques_" . date('dmY') . ".zip a ete creer.");
|
||||
|
||||
// Envoi de mail à MAIL_ADMIN avec le nom du ZIP "CodesUniques_". date('dmY') .".zip"
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new MailExportCodesUniques(Settings::find(1)->name, $nbCodeFic, $nbCodeTot, $nbCodeLigne));
|
||||
}
|
||||
|
||||
private function process($nbCodeFic, $nbCodeTot, $nbCodeLigne, $totalExportedCodes, $currentFilename, $currentExportedCodes, $currentLineCodes, $lastExportedCodeId = null){
|
||||
private function process($nbCodeFic, $nbCodeTot, $nbCodeLigne, $totalExportedCodes, $currentFilename, $currentExportedCodes, $currentLineCodes, $lastExportedCodeId = null)
|
||||
{
|
||||
$paginate = config('codes.paginate');
|
||||
|
||||
if ($nbCodeTot < $paginate){
|
||||
if ($nbCodeTot < $paginate) {
|
||||
$nbCodeToRetrieve = $nbCodeTot;
|
||||
}else{
|
||||
if ($totalExportedCodes + $paginate > $nbCodeTot){
|
||||
} else {
|
||||
if ($totalExportedCodes + $paginate > $nbCodeTot) {
|
||||
$nbCodeToRetrieve = $nbCodeTot - $totalExportedCodes;
|
||||
}else{
|
||||
} else {
|
||||
$nbCodeToRetrieve = $paginate;
|
||||
}
|
||||
}
|
||||
|
||||
if ($lastExportedCodeId === null) {
|
||||
$codes = Codes::where('code_exported', 0)->take($nbCodeToRetrieve)->get();
|
||||
}else{
|
||||
} else {
|
||||
$codes = Codes::where([
|
||||
['code_exported', '=', 0],
|
||||
['id', '>', $lastExportedCodeId]
|
||||
|
|
@ -127,14 +133,14 @@ class ExportCodesUniques extends Command
|
|||
|
||||
$exportedCodesId = [];
|
||||
|
||||
foreach ($codes as $k => $code){
|
||||
if ($currentExportedCodes < $nbCodeTot){
|
||||
if ($currentLineCodes === ($nbCodeLigne === 1 ? 1 : $nbCodeLigne - 1)){
|
||||
foreach ($codes as $k => $code) {
|
||||
if ($currentExportedCodes < $nbCodeTot) {
|
||||
if ($currentLineCodes === ($nbCodeLigne === 1 ? 1 : $nbCodeLigne - 1)) {
|
||||
file_put_contents(storage_path('export_codes_uniques/tmp/') . $currentFilename . ".csv", $code->code_unique . PHP_EOL, FILE_APPEND);
|
||||
$totalExportedCodes++;
|
||||
$currentExportedCodes++;
|
||||
$currentLineCodes = ($nbCodeLigne === 1 ? 1 : 0);
|
||||
}else{
|
||||
} else {
|
||||
file_put_contents(storage_path('export_codes_uniques/tmp/') . $currentFilename . ".csv", $code->code_unique . ";", FILE_APPEND);
|
||||
$totalExportedCodes++;
|
||||
$currentExportedCodes++;
|
||||
|
|
@ -148,11 +154,11 @@ class ExportCodesUniques extends Command
|
|||
$currentFilename++;
|
||||
$currentExportedCodes = 0;
|
||||
}
|
||||
if ((($k + 1) === $countCodes) && $totalExportedCodes < $nbCodeTot){
|
||||
if ((($k + 1) === $countCodes) && $totalExportedCodes < $nbCodeTot) {
|
||||
Codes::whereIn('id', $exportedCodesId)->update(['code_exported' => 1]);
|
||||
return $this->process($nbCodeFic, $nbCodeTot, $nbCodeLigne, $totalExportedCodes, $currentFilename, $currentExportedCodes, $currentLineCodes, $lastExportedCodeId);
|
||||
}
|
||||
if (($k + 1) === $countCodes){
|
||||
if (($k + 1) === $countCodes) {
|
||||
Codes::whereIn('id', $exportedCodesId)->update(['code_exported' => 1]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
|
|
@ -34,7 +35,7 @@ class Kernel extends ConsoleKernel
|
|||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use Throwable;
|
|||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -9,5 +9,7 @@ use Illuminate\Routing\Controller as BaseController;
|
|||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
use AuthorizesRequests;
|
||||
use DispatchesJobs;
|
||||
use ValidatesRequests;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ use App\Models\Settings;
|
|||
|
||||
class EndPageController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$settings = Settings::find(1)->select('start_date', 'end_date', 'activated_close_page', 'close_page_active_date', 'redirect_close')->first();
|
||||
if ($settings->end_date < now() && $settings->activated_close_page === 1 && $settings->close_page_active_date > now())
|
||||
if ($settings->end_date < now() && $settings->activated_close_page === 1 && $settings->close_page_active_date > now()) {
|
||||
return view('front.basic.end', compact('settings'));
|
||||
}
|
||||
return redirect()->route('home');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,30 +21,36 @@ use Illuminate\Support\Facades\Mail;
|
|||
|
||||
class EnterCodeController extends Controller
|
||||
{
|
||||
|
||||
private $apiCrm;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$nbParticipations = Participation::where('user_id', Auth::user()->id)->count();
|
||||
$settings = Settings::find(1)->select('use_ean_codes', 'nb_participation_player')->first();
|
||||
if ($nbParticipations >= $settings->nb_participation_player)
|
||||
$settings = Settings::find(1)->select('use_ean_codes', 'nb_participation_player')->first();
|
||||
if ($nbParticipations >= $settings->nb_participation_player) {
|
||||
return view('front.basic.participation-exhausted', compact('settings'));
|
||||
}
|
||||
return view('front.basic.enter-code', compact('settings'));
|
||||
}
|
||||
|
||||
public function participate(Request $request) {
|
||||
public function participate(Request $request)
|
||||
{
|
||||
// TODO : VALIDATE avec / sans code ean
|
||||
// Récupération des données à utilisées
|
||||
$code = strtoupper($request->code);
|
||||
$code = strtoupper($request->code);
|
||||
$codeBase = Codes::where('code_unique', $code)->first();
|
||||
$settings = Settings::find(1);
|
||||
|
||||
$rules = $request->accept_rules === null ? false : true;
|
||||
if (!$rules)
|
||||
if (!$rules) {
|
||||
return back()->withErrors("Pour participer, vous devez accepter le règlement du jeu.");
|
||||
}
|
||||
|
||||
// Cas IP bannie
|
||||
if (config('app.env') == "local") {
|
||||
|
|
@ -52,38 +58,45 @@ class EnterCodeController extends Controller
|
|||
} else {
|
||||
$ipBanned = BannedIP::where('ip', $_SERVER['HTTP_X_FORWARDED_FOR'])->first() === null ? 0 : 1;
|
||||
}
|
||||
if ($ipBanned)
|
||||
if ($ipBanned) {
|
||||
return view('front.basic.participation-exhausted', compact('settings'));
|
||||
}
|
||||
|
||||
// Cas nombre de participation maximale atteint
|
||||
$nbParticipations = Participation::where('user_id', Auth::user()->id)->count();
|
||||
if ($nbParticipations >= $settings->nb_participation_player)
|
||||
if ($nbParticipations >= $settings->nb_participation_player) {
|
||||
return view('front.basic.participation-exhausted', compact('settings'));
|
||||
}
|
||||
|
||||
// Check le code pour savoir s'il est encore utilisable
|
||||
if (!$codeBase)
|
||||
if (!$codeBase) {
|
||||
return back()->withErrors("Code incorrect, veuillez réessayer.");
|
||||
if ($codeBase->code_used === 1)
|
||||
}
|
||||
if ($codeBase->code_used === 1) {
|
||||
return back()->withErrors("Ce code n'est plus utilisable.");
|
||||
}
|
||||
|
||||
// Check si l'utilisateur n'a pas déjà utiliser ce code
|
||||
$participUser = Participation::where([
|
||||
['code_unique_id', $codeBase->id],
|
||||
['user_id', Auth::user()->id]
|
||||
])->first();
|
||||
if ($participUser)
|
||||
if ($participUser) {
|
||||
return back()->withErrors("Vous avez déjà utilisé ce code.");
|
||||
}
|
||||
|
||||
// Check si les codes ean sont utilisés, auquel cas on test celui envoyé pour savoir s'il est correct
|
||||
$codeEan = null;
|
||||
// TODO : Task Algo Sebastien
|
||||
if ($settings->use_ean_codes === 1) {
|
||||
$codeEan = $request->code_ean;
|
||||
$codeEan = $request->code_ean;
|
||||
$codeEanBase = CodesEAN::where('code', $codeEan)->first();
|
||||
if (!$codeEanBase)
|
||||
if (!$codeEanBase) {
|
||||
$codeEanBase = CodesEAN::where('code', 'like', substr($codeEan, 0, 6) . "%")->first();
|
||||
if (!$codeEanBase || empty($codeEan))
|
||||
}
|
||||
if (!$codeEanBase || empty($codeEan)) {
|
||||
return back()->withErrors('Le code barre entré est incorrect, veuillez réessayer.');
|
||||
}
|
||||
}
|
||||
|
||||
$codeNbUsage = Participation::where('code_unique_id', $codeBase->id)->count();
|
||||
|
|
@ -94,15 +107,16 @@ class EnterCodeController extends Controller
|
|||
$codeBase->save();
|
||||
return back()->withErrors("Ce code n'est plus utilisable.");
|
||||
} else {
|
||||
if ($codeNbUsage + 1 >= $settings->nb_unique_code_use)
|
||||
if ($codeNbUsage + 1 >= $settings->nb_unique_code_use) {
|
||||
$codeBase->code_used = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Tous les cas "bloquants" sont passé, l'utilisateur participe à partir d'ici
|
||||
$participation = new Participation();
|
||||
$participation->user_id = Auth::user()->id;
|
||||
$participation = new Participation();
|
||||
$participation->user_id = Auth::user()->id;
|
||||
$participation->code_unique_id = $codeBase->id;
|
||||
$participation->code_ean_id = isset($codeEanBase) ? $codeEanBase->id : null;
|
||||
$participation->code_ean_id = isset($codeEanBase) ? $codeEanBase->id : null;
|
||||
if (config('app.env') === "local") {
|
||||
$participation->ip = $_SERVER['REMOTE_ADDR'];
|
||||
} else {
|
||||
|
|
@ -120,7 +134,7 @@ class EnterCodeController extends Controller
|
|||
if ($userAlreadyWon) {
|
||||
// Si le jeu est 100% gagnant
|
||||
if ($settings->reductions_activated === 1) {
|
||||
$coupon = $this->getRandomCoupon($settings);
|
||||
$coupon = $this->getRandomCoupon($settings);
|
||||
$crmCoupon = $this->updateCoupon($settings, $coupon->web_coupon_identifiant, $participation);
|
||||
if (!$crmCoupon) {
|
||||
$participation->delete();
|
||||
|
|
@ -135,12 +149,11 @@ class EnterCodeController extends Controller
|
|||
// Gain d'un gros lot
|
||||
$instantWin = InstantWin::where([['appear_date', '<', now()], ['won', 0]])->orderBy('appear_date', 'ASC')->first();
|
||||
if ($instantWin) {
|
||||
$instantWin->won = 1;
|
||||
$instantWin->participation_id = $participation->id;
|
||||
$instantWin->won = 1;
|
||||
$instantWin->participation_id = $participation->id;
|
||||
$participation->instant_win_id = $instantWin->id;
|
||||
// Envoi du courrier Arcadia
|
||||
if ($instantWin->prize->arcadia_operation_code !== 0 && $instantWin->prize->arcadia_support_code !== 0) {
|
||||
|
||||
$crmId = Auth::user()->crm_id;
|
||||
|
||||
$fields = [
|
||||
|
|
@ -171,7 +184,7 @@ class EnterCodeController extends Controller
|
|||
];
|
||||
|
||||
if ($settings->use_ean_codes === 1) {
|
||||
$codeEan = $request->code_ean;
|
||||
$codeEan = $request->code_ean;
|
||||
$fields['orderLine'][] = [
|
||||
'fieldName' => 'code_on_pack',
|
||||
'fieldValue' => "$codeEan"
|
||||
|
|
@ -179,7 +192,7 @@ class EnterCodeController extends Controller
|
|||
}
|
||||
|
||||
$arcadiaMail = $this->apiCrm->ArcadiaOutgoingMail($crmId, $fields, 'game');
|
||||
if ($arcadiaMail->status === 'NOK'){
|
||||
if ($arcadiaMail->status === 'NOK') {
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new CourrierArcadiaError(Auth::user()));
|
||||
}
|
||||
}
|
||||
|
|
@ -187,14 +200,15 @@ class EnterCodeController extends Controller
|
|||
$instantWin->save();
|
||||
Mail::to(Auth::user()->email)->send(new PrizeWon(Auth::user(), $instantWin->prize, $settings));
|
||||
$mails = json_decode($settings->notification_emails);
|
||||
foreach ($mails as $mail)
|
||||
foreach ($mails as $mail) {
|
||||
Mail::to($mail->email)->send(new NotifWinAdmin($settings, $participation));
|
||||
}
|
||||
$participation->save();
|
||||
return view("front.basic." . $instantWin->prize->gain_view->file_name, compact('settings'))->with('prize', $instantWin->prize);
|
||||
}
|
||||
// Si le jeu est 100% gagnant
|
||||
if ($settings->reductions_activated === 1) {
|
||||
$coupon = $this->getRandomCoupon($settings);
|
||||
$coupon = $this->getRandomCoupon($settings);
|
||||
$crmCoupon = $this->updateCoupon($settings, $coupon->web_coupon_identifiant, $participation);
|
||||
if (!$crmCoupon) {
|
||||
$participation->delete();
|
||||
|
|
@ -208,15 +222,19 @@ class EnterCodeController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
private function getRandomCoupon($settings) {
|
||||
private function getRandomCoupon($settings)
|
||||
{
|
||||
$webCoupons = json_decode($settings->web_coupons);
|
||||
if (count($webCoupons) > 1) {
|
||||
$lots = [];
|
||||
foreach($webCoupons as $webCoupon)
|
||||
foreach ($webCoupons as $webCoupon) {
|
||||
$lots[] = $webCoupon;
|
||||
foreach ($lots as $lot)
|
||||
for ($i = 0; $i < $lot->percentage; $i++)
|
||||
}
|
||||
foreach ($lots as $lot) {
|
||||
for ($i = 0; $i < $lot->percentage; $i++) {
|
||||
$tmp[] = $lot;
|
||||
}
|
||||
}
|
||||
shuffle($tmp);
|
||||
return $tmp[0];
|
||||
} else {
|
||||
|
|
@ -224,32 +242,34 @@ class EnterCodeController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
private function updateCoupon($settings, $coupon, $participation) {
|
||||
private function updateCoupon($settings, $coupon, $participation)
|
||||
{
|
||||
$reduction = null;
|
||||
$mesBR = new MesBR(config('mesbr.endpoint'), $settings->reductions_site, $settings->reductions_campaign);
|
||||
$mesBR = new MesBR(config('mesbr.endpoint'), $settings->reductions_site, $settings->reductions_campaign);
|
||||
|
||||
$crmUser = $this->apiCrm->getCustomer(Auth::user()->crm_id);
|
||||
if ($crmUser->status === 'OK'){
|
||||
if ($crmUser->status === 'OK') {
|
||||
$mesBR->updateContact($crmUser->user);
|
||||
$result = $mesBR->updatePanier($crmUser->user, $coupon);
|
||||
if ($result["status"] === "OK") {
|
||||
$reduction = new Reductions();
|
||||
$reduction = new Reductions();
|
||||
$reduction->participation_id = $participation->id;
|
||||
$reduction->link = $result["link"];
|
||||
$reduction->verification = $result["verif"];
|
||||
$reduction->basket_id = $result["basketId"];
|
||||
$reduction->link = $result["link"];
|
||||
$reduction->verification = $result["verif"];
|
||||
$reduction->basket_id = $result["basketId"];
|
||||
$reduction->save();
|
||||
$participation->reduction_id = $reduction->id;
|
||||
$participation->save();
|
||||
}else{
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new NotifAdmin("MESBR : Une erreur est survenue. Code : " . $result["code"] . " Message : ". $result["message"]));
|
||||
} else {
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new NotifAdmin("MESBR : Une erreur est survenue. Code : " . $result["code"] . " Message : " . $result["message"]));
|
||||
}
|
||||
}
|
||||
|
||||
return $reduction;
|
||||
}
|
||||
|
||||
public function formWinningProof() {
|
||||
public function formWinningProof()
|
||||
{
|
||||
$participation = Participation::where([
|
||||
['user_id', Auth::user()->id],
|
||||
['instant_win_id', '<>', null],
|
||||
|
|
@ -257,8 +277,9 @@ class EnterCodeController extends Controller
|
|||
['ticket', null],
|
||||
['barcode', null]
|
||||
])->first();
|
||||
if ($participation)
|
||||
if ($participation) {
|
||||
return view('front.basic.winning-proof', compact('participation'));
|
||||
}
|
||||
return redirect()->route('home');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@ use App\Models\FaqThemes;
|
|||
|
||||
class FAQController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$questions = FaqQuestions::all();
|
||||
$themes = FaqThemes::all();
|
||||
if (count($questions) === 0 && count($themes) === 0)
|
||||
$themes = FaqThemes::all();
|
||||
if (count($questions) === 0 && count($themes) === 0) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
return view('front.basic.faq', compact('questions', 'themes'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@ namespace App\Http\Controllers;
|
|||
|
||||
class GainsController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
if (view()->exists('front.basic.gains'))
|
||||
public function index()
|
||||
{
|
||||
if (view()->exists('front.basic.gains')) {
|
||||
return view('front.basic.gains');
|
||||
}
|
||||
return redirect()->route('home');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Prizes;
|
||||
|
||||
class HowToPlayController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
if (view()->exists('front.basic.how-to-play'))
|
||||
public function index()
|
||||
{
|
||||
if (view()->exists('front.basic.how-to-play')) {
|
||||
return view('front.basic.how-to-play');
|
||||
}
|
||||
return redirect()->route('home');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use App\User;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
|
@ -18,12 +17,14 @@ class LoginController extends Controller
|
|||
|
||||
private $apiCrm;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
return view('front.basic.login');
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +35,7 @@ class LoginController extends Controller
|
|||
'password' => 'required',
|
||||
]);
|
||||
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_EMAIL);
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_EMAIL);
|
||||
$password = $request->password;
|
||||
$remember = $request->remember !== null ? true : false;
|
||||
|
||||
|
|
@ -43,13 +44,12 @@ class LoginController extends Controller
|
|||
if ($userLocal) {
|
||||
if ($userLocal->email_verified === 1) {
|
||||
if ($userLocal->role > 2) {
|
||||
|
||||
$connect = $this->apiCrm->loginCustomer($email, $password);
|
||||
|
||||
if ($connect->status === 'KO'){
|
||||
if ($connect->status === 'KO') {
|
||||
if ($connect->code === 500) {
|
||||
return back()->withInput($request->except("password"))->withErrors("La connexion est impossible pour le moment, veuillez réessayer plus tard.");
|
||||
}else{
|
||||
} else {
|
||||
return back()->withInput($request->except("password"))->withErrors("Email ou mot de passe incorrect.");
|
||||
}
|
||||
}
|
||||
|
|
@ -58,14 +58,12 @@ class LoginController extends Controller
|
|||
$userLocal->email_verify_token = Str::uuid();
|
||||
$userLocal->save();
|
||||
Mail::to($email)->send(new VerifyEmail($userLocal));
|
||||
return back()->withInput($request->except( "password"))->withErrors("Votre compte existe mais votre email n'est pas confirmé, merci de vérifier vos emails.");
|
||||
return back()->withInput($request->except("password"))->withErrors("Votre compte existe mais votre email n'est pas confirmé, merci de vérifier vos emails.");
|
||||
}
|
||||
} else {
|
||||
|
||||
$connect = $this->apiCrm->loginCustomer($email, $password);
|
||||
|
||||
if ($connect->status === 'OK'){
|
||||
|
||||
if ($connect->status === 'OK') {
|
||||
$userLocal = User::create([
|
||||
'crm_id' => $connect->user->crm_id,
|
||||
'firstname' => $connect->user->firstname,
|
||||
|
|
@ -80,11 +78,8 @@ class LoginController extends Controller
|
|||
'country' => $connect->user->country,
|
||||
'email_verified' => 1
|
||||
]);
|
||||
|
||||
}else{
|
||||
|
||||
} else {
|
||||
if ($connect->code === 116) { // Compte existant mais non activé
|
||||
|
||||
$userLocal = User::create([
|
||||
'crm_id' => $connect->user->crm_id,
|
||||
'firstname' => $connect->user->firstname,
|
||||
|
|
@ -102,11 +97,10 @@ class LoginController extends Controller
|
|||
$userLocal->email_verify_token = Str::uuid();
|
||||
$userLocal->save();
|
||||
Mail::to($email)->send(new VerifyEmail($userLocal));
|
||||
return back()->withInput($request->except( "password"))->withErrors("Votre compte existe mais votre email n'est pas confirmé, merci de vérifier vos emails.");
|
||||
|
||||
}elseif ($connect->code === 500){
|
||||
return back()->withInput($request->except("password"))->withErrors("Votre compte existe mais votre email n'est pas confirmé, merci de vérifier vos emails.");
|
||||
} elseif ($connect->code === 500) {
|
||||
return back()->withInput($request->except("password"))->withErrors("La connexion est impossible pour le moment, veuillez réessayer plus tard.");
|
||||
}else{
|
||||
} else {
|
||||
return back()->withInput($request->except("password"))->withErrors("Email ou mot de passe incorrect.");
|
||||
}
|
||||
}
|
||||
|
|
@ -114,42 +108,45 @@ class LoginController extends Controller
|
|||
|
||||
// TODO : Modifier avec separation guard
|
||||
$tmpPwd = "MOTDEPASSE";
|
||||
if ($userLocal->role <= 2)
|
||||
if ($userLocal->role <= 2) {
|
||||
$tmpPwd = $password;
|
||||
}
|
||||
|
||||
if (Auth::attempt(["email" => $email, "password" => $tmpPwd], $remember)) {
|
||||
if ($userLocal->role <= 2)
|
||||
if ($userLocal->role <= 2) {
|
||||
return redirect()->route('bo.dashboard');
|
||||
}
|
||||
return redirect()->route('saisir-code');
|
||||
} else {
|
||||
return back()->withInput($request->except('password'))->withErrors('Les identifiants entrés sont incorrects.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
public function logout()
|
||||
{
|
||||
Auth::logout();
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
public function confirmEmail($verifyToken) {
|
||||
public function confirmEmail($verifyToken)
|
||||
{
|
||||
$result = false;
|
||||
$user = User::where('email_verify_token', $verifyToken)->first();
|
||||
if (!$user)
|
||||
$user = User::where('email_verify_token', $verifyToken)->first();
|
||||
if (!$user) {
|
||||
return view('front.basic.confirm-email', compact('result'));
|
||||
}
|
||||
|
||||
$activation = $this->apiCrm->activateCustomer($user->crm_id);
|
||||
|
||||
if ($activation->status === 'OK'){
|
||||
$user->email_verified = 1;
|
||||
$user->email_verify_token = NULL;
|
||||
if ($activation->status === 'OK') {
|
||||
$user->email_verified = 1;
|
||||
$user->email_verify_token = null;
|
||||
$user->save();
|
||||
$result = true;
|
||||
}else{
|
||||
if ($activation->code === 110){ // User already active
|
||||
$user->email_verified = 1;
|
||||
$user->email_verify_token = NULL;
|
||||
} else {
|
||||
if ($activation->code === 110) { // User already active
|
||||
$user->email_verified = 1;
|
||||
$user->email_verify_token = null;
|
||||
$user->save();
|
||||
$result = true;
|
||||
}
|
||||
|
|
@ -158,33 +155,38 @@ class LoginController extends Controller
|
|||
return view('front.basic.confirm-email', compact('result'));
|
||||
}
|
||||
|
||||
public function forgotPassword(Request $request) {
|
||||
public function forgotPassword(Request $request)
|
||||
{
|
||||
if ($request->tokenValid && $request->token) {
|
||||
$tokenValid = $request->tokenValid;
|
||||
$token = $request->token;
|
||||
$token = $request->token;
|
||||
return view('front.basic.forgot-password', compact('tokenValid', 'token'));
|
||||
}
|
||||
return view('front.basic.forgot-password');
|
||||
}
|
||||
|
||||
public function forgotPasswordReset(Request $request, $token) {
|
||||
if (!$request->hasValidSignature(false))
|
||||
public function forgotPasswordReset(Request $request, $token)
|
||||
{
|
||||
if (!$request->hasValidSignature(false)) {
|
||||
return redirect()->route('login')->withErrors("Le lien de changement de votre mot de passe n'est plus valide, veuillez réessayer.");
|
||||
}
|
||||
$tokenValid = false;
|
||||
$user = User::where('password_token', $token)->first();
|
||||
if (!$user)
|
||||
$user = User::where('password_token', $token)->first();
|
||||
if (!$user) {
|
||||
return redirect()->route('forgot-password', compact('tokenValid'))->withErrors('Le lien de changement du mot de passe est incorrect.');
|
||||
}
|
||||
$tokenValid = true;
|
||||
return redirect()->route('forgot-password', compact('tokenValid', 'token'));
|
||||
}
|
||||
|
||||
public function mailPassword(Request $request) {
|
||||
public function mailPassword(Request $request)
|
||||
{
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_STRING);
|
||||
$user = User::where('email', $email)->first();
|
||||
$user = User::where('email', $email)->first();
|
||||
|
||||
if (!$user) {
|
||||
$userCrm = $this->apiCrm->getCustomerByEmail($email);
|
||||
if ($userCrm->status === 'OK'){
|
||||
if ($userCrm->status === 'OK') {
|
||||
$user = User::create([
|
||||
'crm_id' => $userCrm->user->crm_id,
|
||||
'firstname' => $userCrm->user->firstname,
|
||||
|
|
@ -200,18 +202,17 @@ class LoginController extends Controller
|
|||
'email_verified' => 1
|
||||
]);
|
||||
|
||||
if ($userCrm->user->status === 0){
|
||||
$user->email_verified = 0;
|
||||
if ($userCrm->user->status === 0) {
|
||||
$user->email_verified = 0;
|
||||
$user->email_verify_token = Str::uuid();
|
||||
$user->save();
|
||||
Mail::to($email)->send(new VerifyEmail($user));
|
||||
return back()->withInput($request->except( "password"))->withErrors("Votre compte existe mais votre email n'est pas confirmé, merci de vérifier vos emails.");
|
||||
return back()->withInput($request->except("password"))->withErrors("Votre compte existe mais votre email n'est pas confirmé, merci de vérifier vos emails.");
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
if ($userCrm->code === 101) {
|
||||
return back()->withInput($request->only('email'))->withErrors("Le mail que vous avez entré n'est pas enregistré dans nos services.");
|
||||
}else{
|
||||
} else {
|
||||
return back()->withErrors("Une erreur est survenue, veuillez réessayer plus tard.");
|
||||
}
|
||||
}
|
||||
|
|
@ -224,28 +225,30 @@ class LoginController extends Controller
|
|||
return redirect()->route('login')->with('success', 'Un mail de réinitialisation de votre mot de passe vous a été envoyé(e).');
|
||||
}
|
||||
|
||||
public function changePassword(Request $request) {
|
||||
public function changePassword(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'password' => 'required|min:8|confirmed',
|
||||
]);
|
||||
|
||||
$user = User::where('password_token', filter_var($request->token, FILTER_SANITIZE_STRING))->first();
|
||||
if (!$user)
|
||||
if (!$user) {
|
||||
return back()->withErrors('Le lien de changement de votre mot de passe est incorrect, veuillez réessayer.');
|
||||
}
|
||||
|
||||
// TODO : Ajouter controle du contenu du mot de passe
|
||||
$newPassword = $request->password;
|
||||
|
||||
$update = $this->apiCrm->changePwdCustomer($user->crm_id, $newPassword);
|
||||
|
||||
if ($update->status === 'OK'){
|
||||
$user->password_token = NULL;
|
||||
if ($update->status === 'OK') {
|
||||
$user->password_token = null;
|
||||
$user->save();
|
||||
return redirect()->route('login')->with('success', 'Vous pouvez désormais vous connecter avec votre nouveau mot de passe.');
|
||||
}else{
|
||||
if ($update->code === 123){
|
||||
} else {
|
||||
if ($update->code === 123) {
|
||||
return back()->withErrors("Il semblerait que vous ayez déjà utilisé ce mot de passe pour votre compte. Veuillez réessayer en changeant de mot de passe.");
|
||||
}else{
|
||||
} else {
|
||||
return back()->withErrors("Une erreur est survenue, veuillez réessayer plus tard.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,15 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProduitsController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$products = Product::all();
|
||||
if (view()->exists('front.basic.produits-porteurs'))
|
||||
return view('front.basic.produits-porteurs', compact('products'));
|
||||
if (view()->exists('front.basic.produits-porteurs')) {
|
||||
return view('front.basic.produits-porteurs', compact('products', 'ranges'));
|
||||
}
|
||||
return redirect()->route('home');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,11 +27,13 @@ class RegisterController extends Controller
|
|||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
return view('front.basic.register-crm');
|
||||
}
|
||||
|
||||
public function register(Request $request) {
|
||||
public function register(Request $request)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'lastname' => 'required|string|max:255',
|
||||
|
|
@ -47,37 +49,38 @@ class RegisterController extends Controller
|
|||
'reglement' => 'accepted',
|
||||
]);
|
||||
|
||||
$lastname = filter_var($request->lastname, FILTER_SANITIZE_STRING);
|
||||
$lastname = filter_var($request->lastname, FILTER_SANITIZE_STRING);
|
||||
$firstname = filter_var($request->firstname, FILTER_SANITIZE_STRING);
|
||||
$birthdate = $request->birth_date;
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_EMAIL);
|
||||
$password = $request->password;
|
||||
$address = filter_var($request->address, FILTER_SANITIZE_STRING);
|
||||
$address2 = $request->address2 !== null ? filter_var($request->address2, FILTER_SANITIZE_STRING) : null;
|
||||
$town = filter_var($request->town, FILTER_SANITIZE_STRING);
|
||||
$postcode = filter_var($request->postal_code, FILTER_SANITIZE_STRING);
|
||||
$country = filter_var($request->country, FILTER_SANITIZE_STRING);
|
||||
$optin = $request->news !== null ? 1 : 0;
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_EMAIL);
|
||||
$password = $request->password;
|
||||
$address = filter_var($request->address, FILTER_SANITIZE_STRING);
|
||||
$address2 = $request->address2 !== null ? filter_var($request->address2, FILTER_SANITIZE_STRING) : null;
|
||||
$town = filter_var($request->town, FILTER_SANITIZE_STRING);
|
||||
$postcode = filter_var($request->postal_code, FILTER_SANITIZE_STRING);
|
||||
$country = filter_var($request->country, FILTER_SANITIZE_STRING);
|
||||
$optin = $request->news !== null ? 1 : 0;
|
||||
$tokenMail = Str::uuid();
|
||||
|
||||
$MJ = Carbon::now()->subYears(18);
|
||||
|
||||
if ($this->isSQLDate($birthdate)){
|
||||
if ($this->isSQLDate($birthdate)) {
|
||||
$d = Carbon::createFromFormat('Y-m-d', $birthdate);
|
||||
if (!$d->lessThanOrEqualTo($MJ))
|
||||
if (!$d->lessThanOrEqualTo($MJ)) {
|
||||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Vous devez être majeur pour vous inscrire au jeu.");
|
||||
}elseif ($this->isFormDate($birthdate)){
|
||||
}
|
||||
} elseif ($this->isFormDate($birthdate)) {
|
||||
$d = Carbon::createFromFormat('d/m/Y', $birthdate);
|
||||
if (!$d->lessThanOrEqualTo($MJ))
|
||||
if (!$d->lessThanOrEqualTo($MJ)) {
|
||||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Vous devez être majeur pour vous inscrire au jeu.");
|
||||
}
|
||||
|
||||
$birthdate = $d->toDateString();
|
||||
|
||||
}else{
|
||||
} else {
|
||||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Erreur sur le champs : date de naissance.");
|
||||
|
|
@ -85,8 +88,7 @@ class RegisterController extends Controller
|
|||
|
||||
$crmUser = $this->apiCrm->createCustomer($email, $password, $firstname, $lastname, $optin, $birthdate, null, $address, $address2, $town, $postcode, ucfirst($country));
|
||||
|
||||
if ($crmUser->status === 'OK'){
|
||||
|
||||
if ($crmUser->status === 'OK') {
|
||||
$user = User::create([
|
||||
'crm_id' => $crmUser->user->crm_id,
|
||||
'firstname' => $firstname,
|
||||
|
|
@ -110,13 +112,12 @@ class RegisterController extends Controller
|
|||
"- Vérifiez vos spams : l'email de confirmation s'y trouve peut-être<br>" .
|
||||
"- Attention : le mail peut parfois mettre quelques minutes à vous parvenir<br>" .
|
||||
"- L'activation de votre compte doit se faire dans les 24 heures qui suivent la demande de création.");
|
||||
|
||||
}else{
|
||||
if ($crmUser->code === 103){
|
||||
} else {
|
||||
if ($crmUser->code === 103) {
|
||||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Un compte utilisateur est déjà associé à votre email.");
|
||||
}else{
|
||||
} else {
|
||||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Une erreur est survenue, merci de recommencer.");
|
||||
|
|
@ -124,15 +125,19 @@ class RegisterController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
private function isSQLDate($date){
|
||||
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $date))
|
||||
private function isSQLDate($date)
|
||||
{
|
||||
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $date)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isFormDate($date){
|
||||
if (preg_match("/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/[0-9]{4}$/", $date))
|
||||
private function isFormDate($date)
|
||||
{
|
||||
if (preg_match("/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/[0-9]{4}$/", $date)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,16 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Prizes;
|
||||
use App\Models\Settings;
|
||||
|
||||
class TeaserController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$settings = Settings::find(1)->select('start_date', 'end_date', 'activated_teaser', 'teaser_end_activity')->first();
|
||||
if ($settings->activated_teaser === 1 && $settings->teaser_end_activity > now())
|
||||
if ($settings->activated_teaser === 1 && $settings->teaser_end_activity > now()) {
|
||||
return view('front.basic.teaser', compact('settings'));
|
||||
}
|
||||
return redirect()->route('home');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,17 +6,20 @@ use App\Models\Content;
|
|||
|
||||
class ViewContentController extends Controller
|
||||
{
|
||||
public function reglement() {
|
||||
public function reglement()
|
||||
{
|
||||
$content = Content::find(3);
|
||||
return view('front.basic.reglement', compact('content'));
|
||||
}
|
||||
|
||||
public function charte() {
|
||||
public function charte()
|
||||
{
|
||||
$content = Content::find(2);
|
||||
return view('front.basic.charte', compact('content'));
|
||||
}
|
||||
|
||||
public function legals() {
|
||||
public function legals()
|
||||
{
|
||||
$content = Content::find(1);
|
||||
return view('front.basic.legals', compact('content'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,13 +14,16 @@ use Illuminate\Support\Facades\Mail;
|
|||
|
||||
class WinningProofController extends Controller
|
||||
{
|
||||
|
||||
private $apiCrm;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
public function sendWinningProof(Request $request) {
|
||||
public function sendWinningProof(Request $request)
|
||||
{
|
||||
// On récupère la participation gagnante en attente des infos
|
||||
$participation = Participation::where([
|
||||
['user_id', Auth::user()->id],
|
||||
|
|
@ -29,8 +32,9 @@ class WinningProofController extends Controller
|
|||
['ticket', null],
|
||||
['barcode', null]
|
||||
])->first();
|
||||
if (!$participation)
|
||||
if (!$participation) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'lastname' => 'required|string|max:255',
|
||||
|
|
@ -46,35 +50,35 @@ class WinningProofController extends Controller
|
|||
'barcode' => 'required|mimes:jpeg,png,jpg,pdf|max:2048',
|
||||
]);
|
||||
|
||||
$lastname = filter_var($request->lastname, FILTER_SANITIZE_STRING);
|
||||
$firstname = filter_var($request->firstname, FILTER_SANITIZE_STRING);
|
||||
$address = filter_var($request->address, FILTER_SANITIZE_STRING);
|
||||
$address2 = $request->address2 !== null ? filter_var($request->address2, FILTER_SANITIZE_STRING) : null;
|
||||
$town = filter_var($request->town, FILTER_SANITIZE_STRING);
|
||||
$lastname = filter_var($request->lastname, FILTER_SANITIZE_STRING);
|
||||
$firstname = filter_var($request->firstname, FILTER_SANITIZE_STRING);
|
||||
$address = filter_var($request->address, FILTER_SANITIZE_STRING);
|
||||
$address2 = $request->address2 !== null ? filter_var($request->address2, FILTER_SANITIZE_STRING) : null;
|
||||
$town = filter_var($request->town, FILTER_SANITIZE_STRING);
|
||||
$postalCode = filter_var($request->postal_code, FILTER_SANITIZE_STRING);
|
||||
$country = filter_var($request->country, FILTER_SANITIZE_STRING);
|
||||
$phone = filter_var($request->phone, FILTER_SANITIZE_STRING);
|
||||
$sticker = $request->sticker;
|
||||
$ticket = $request->ticket;
|
||||
$barcode = $request->barcode;
|
||||
$country = filter_var($request->country, FILTER_SANITIZE_STRING);
|
||||
$phone = filter_var($request->phone, FILTER_SANITIZE_STRING);
|
||||
$sticker = $request->sticker;
|
||||
$ticket = $request->ticket;
|
||||
$barcode = $request->barcode;
|
||||
|
||||
// Mise à jour de l'utilisateur en local
|
||||
$user = User::find(Auth::user()->id);
|
||||
$user->lastname = $lastname;
|
||||
$user->firstname = $firstname;
|
||||
$user->address = $address;
|
||||
$user->address2 = $address2;
|
||||
$user->town = $town;
|
||||
$user = User::find(Auth::user()->id);
|
||||
$user->lastname = $lastname;
|
||||
$user->firstname = $firstname;
|
||||
$user->address = $address;
|
||||
$user->address2 = $address2;
|
||||
$user->town = $town;
|
||||
$user->postal_code = $postalCode;
|
||||
$user->country = $country;
|
||||
$user->phone = $phone;
|
||||
$user->country = $country;
|
||||
$user->phone = $phone;
|
||||
$user->save();
|
||||
|
||||
// Mise à jour utilisateur dans la CRM
|
||||
$update = $this->apiCrm->updateCustomer($user->crm_id, $firstname, $lastname, null, null, $phone, $address, $address2, $town, $postalCode, ucfirst($country));
|
||||
if ($update->status !== 'OK'){
|
||||
Log::warning('Erreur lors de la mise a jour du user (crm_id : ' . $user->crm_id . ') - code : '. $update->code.' - message : '. $update->message);
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new NotifAdmin('CRM : Erreur lors de la mise a jour du user (crm_id : ' . $user->crm_id . ') - code : '. $update->code.' - message : '. $update->message));
|
||||
if ($update->status !== 'OK') {
|
||||
Log::warning('Erreur lors de la mise a jour du user (crm_id : ' . $user->crm_id . ') - code : ' . $update->code . ' - message : ' . $update->message);
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new NotifAdmin('CRM : Erreur lors de la mise a jour du user (crm_id : ' . $user->crm_id . ') - code : ' . $update->code . ' - message : ' . $update->message));
|
||||
}
|
||||
|
||||
$participationId = $participation->id;
|
||||
|
|
@ -91,12 +95,12 @@ class WinningProofController extends Controller
|
|||
$barcodePath = public_path() . '/fichiers/preuve-de-gain/' . $participationId . '/' . $barcodeFileName;
|
||||
|
||||
$participation->sticker = $stickerFileName;
|
||||
$participation->ticket = $ticketFileName;
|
||||
$participation->ticket = $ticketFileName;
|
||||
$participation->barcode = $barcodeFileName;
|
||||
$participation->save();
|
||||
|
||||
$settings = Settings::find(1);
|
||||
$mails = json_decode($settings->notification_emails);
|
||||
$mails = json_decode($settings->notification_emails);
|
||||
foreach ($mails as $mail) {
|
||||
Mail::to($mail->email)->send(new WinningProof($stickerPath, $ticketPath, $barcodePath, $participation, $user, $settings));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ use Illuminate\Http\Request;
|
|||
|
||||
class BannedIPController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$ips = BannedIP::all();
|
||||
return view('bo.banned-ip.index', compact('ips'));
|
||||
}
|
||||
|
||||
public function saveDatas(Request $request) {
|
||||
public function saveDatas(Request $request)
|
||||
{
|
||||
$ips = $request->ips;
|
||||
|
||||
for ($i = 0; $i < count($ips); $i++) {
|
||||
|
|
@ -28,7 +30,8 @@ class BannedIPController extends Controller
|
|||
return $ips;
|
||||
}
|
||||
|
||||
public function destroy(Request $request) {
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$ip = BannedIP::where("ip", $request->ip);
|
||||
$ip->delete();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,32 +7,34 @@ use App\Jobs\ProcessExportCodesUniques;
|
|||
use App\Jobs\ProcessUniqueCode;
|
||||
use App\Models\Codes;
|
||||
use App\Models\Settings;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CodesController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
$nbCodeBase = Codes::count();
|
||||
$nbCodeUsed = Codes::where('code_used', 1)->count();
|
||||
$nbCodeExported = Codes::where('code_exported', 1)->count();
|
||||
public function index()
|
||||
{
|
||||
$nbCodeBase = Codes::count();
|
||||
$nbCodeUsed = Codes::where('code_used', 1)->count();
|
||||
$nbCodeExported = Codes::where('code_exported', 1)->count();
|
||||
$nbCodeRemainingToExport = Codes::where('code_exported', 0)->count();
|
||||
return view('bo.codes.index', compact('nbCodeBase', 'nbCodeUsed', 'nbCodeExported', 'nbCodeRemainingToExport'));
|
||||
}
|
||||
|
||||
public function generate(Request $request) {
|
||||
$quantity = $request->quantity;
|
||||
public function generate(Request $request)
|
||||
{
|
||||
$quantity = $request->quantity;
|
||||
$codeLength = $request->code_length;
|
||||
$settings = Settings::find(1);
|
||||
$settings = Settings::find(1);
|
||||
|
||||
ProcessUniqueCode::dispatch($quantity, $codeLength, $settings);
|
||||
|
||||
return back()->with('success', "La génération à commencée, un mail de notification sera envoyé à l'adresse " . config('mail.MAIL_ADMIN') . " lorsque le traitement sera terminé.");
|
||||
}
|
||||
|
||||
public function export(Request $request) {
|
||||
$nbCodeFic = intval($request->nb_code_fic);
|
||||
$nbCodeTot = intval($request->nb_code_tot);
|
||||
public function export(Request $request)
|
||||
{
|
||||
$nbCodeFic = intval($request->nb_code_fic);
|
||||
$nbCodeTot = intval($request->nb_code_tot);
|
||||
$nbCodeLigne = intval($request->nb_code_ligne);
|
||||
|
||||
ProcessExportCodesUniques::dispatch($nbCodeFic, $nbCodeTot, $nbCodeLigne);
|
||||
|
|
|
|||
|
|
@ -8,24 +8,26 @@ use Illuminate\Http\Request;
|
|||
|
||||
class CodesEANController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$ean = CodesEAN::all();
|
||||
return view('bo.codes-ean.index', compact('ean'));
|
||||
}
|
||||
|
||||
public function saveDatas(Request $request) {
|
||||
public function saveDatas(Request $request)
|
||||
{
|
||||
$codes = $request->codes;
|
||||
|
||||
for ($i = 0; $i < count($codes); $i++) {
|
||||
$codeToInsert = !empty($codes[$i]["code"]) && !empty($codes[$i]["product"]);
|
||||
if (isset($codes[$i]["id"]) && $codes[$i]["id"] !== null && $codeToInsert) {
|
||||
$c = CodesEAN::findOrFail($codes[$i]["id"]);
|
||||
$c->code = $codes[$i]["code"];
|
||||
$c = CodesEAN::findOrFail($codes[$i]["id"]);
|
||||
$c->code = $codes[$i]["code"];
|
||||
$c->product = $codes[$i]["product"];
|
||||
$c->save();
|
||||
} else {
|
||||
if ($codeToInsert) {
|
||||
$c = CodesEAN::updateOrCreate(['code' => $codes[$i]["code"], 'product' => $codes[$i]["product"]]);
|
||||
$c = CodesEAN::updateOrCreate(['code' => $codes[$i]["code"], 'product' => $codes[$i]["product"]]);
|
||||
$codes[$i]["id"] = $c->id;
|
||||
} else {
|
||||
unset($codes[$i]);
|
||||
|
|
@ -37,7 +39,8 @@ class CodesEANController extends Controller
|
|||
return $codes;
|
||||
}
|
||||
|
||||
public function destroy(Request $request) {
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$code = CodesEAN::findOrFail($request->id);
|
||||
$code->delete();
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@ use Illuminate\Http\Request;
|
|||
|
||||
class ContentController extends Controller
|
||||
{
|
||||
public function manage($id, Request $request) {
|
||||
public function manage($id, Request $request)
|
||||
{
|
||||
$content = Content::findOrFail($id);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$value = $request->value;
|
||||
$value = $request->value;
|
||||
$content->value = $value;
|
||||
$content->save();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
|
|||
use App\Models\Participation;
|
||||
use App\Models\Settings;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DashboardController extends Controller
|
||||
|
|
@ -14,42 +13,43 @@ class DashboardController extends Controller
|
|||
public function index()
|
||||
{
|
||||
// Pour les stats
|
||||
$settings = Settings::find(1);
|
||||
$participations = Participation::selectRaw("COUNT(*) AS count, DATE(created_at) AS date")->groupByRaw("DATE(created_at)")->get();
|
||||
$settings = Settings::find(1);
|
||||
$participations = Participation::selectRaw("COUNT(*) AS count, DATE(created_at) AS date")->groupByRaw("DATE(created_at)")->get();
|
||||
$participationsUniquePerDay = Participation::selectRaw("DISTINCT user_id AS user, COUNT(*) AS count, DATE(created_at) AS date")->groupByRaw("DATE(created_at), user")->get();
|
||||
$statsUnique = [];
|
||||
foreach($participationsUniquePerDay as $participationPerDay) {
|
||||
$dateUnique = Carbon::parse($participationPerDay->date)->format('d/m/Y');
|
||||
$statsUnique = [];
|
||||
foreach ($participationsUniquePerDay as $participationPerDay) {
|
||||
$dateUnique = Carbon::parse($participationPerDay->date)->format('d/m/Y');
|
||||
$statsUnique[$dateUnique] = isset($statsUnique[$dateUnique]) ? $statsUnique[$dateUnique] + 1 : 1;
|
||||
}
|
||||
$participationsUnique = Participation::selectRaw("DISTINCT user_id AS user, COUNT(*) AS count")->groupBy("user")->orderBy("user")->get();
|
||||
|
||||
// Données calculées à afficher
|
||||
$totalParticipation = Participation::count();
|
||||
if (count($participationsUnique) > 0){
|
||||
if (count($participationsUnique) > 0) {
|
||||
$avgParticipUser = round($totalParticipation / count($participationsUnique), 1);
|
||||
} else {
|
||||
$avgParticipUser = 0;
|
||||
}
|
||||
|
||||
// Tableau des dates comprises dans la table participation
|
||||
foreach ($participations as $participation)
|
||||
foreach ($participations as $participation) {
|
||||
$datesParticipations[Carbon::parse($participation->date)->format('d/m/Y')] = $participation->count;
|
||||
}
|
||||
|
||||
// Création des tableaux avec toutes les dates depuis le début du jeu et le nombre de participations associées
|
||||
$date = Carbon::parse($settings->start_date);
|
||||
$date = Carbon::parse($settings->start_date);
|
||||
$dateFin = now() < $settings->end_date ? Carbon::now() : Carbon::parse($settings->end_date);
|
||||
|
||||
// Récupération des 3 codes EAN les plus utilisés
|
||||
$codesEan = Participation::select(DB::raw('COUNT(code_ean_id) AS nb_usage, code_ean_id'))->groupBy('code_ean_id')->orderByDesc('nb_usage')->limit(3)->get();
|
||||
|
||||
// Génération des tableaux de date depuis le début du jeu
|
||||
$dates = [];
|
||||
$count = [];
|
||||
$dates = [];
|
||||
$count = [];
|
||||
$countUnique = [];
|
||||
while ($dateFin > $date) {
|
||||
$dates[] = $date->format('d/m/Y');
|
||||
$count[] = isset($datesParticipations[$date->format('d/m/Y')]) ? $datesParticipations[$date->format('d/m/Y')] : 0;
|
||||
$dates[] = $date->format('d/m/Y');
|
||||
$count[] = isset($datesParticipations[$date->format('d/m/Y')]) ? $datesParticipations[$date->format('d/m/Y')] : 0;
|
||||
$countUnique[] = isset($statsUnique[$date->format('d/m/Y')]) ? $statsUnique[$date->format('d/m/Y')] : 0;
|
||||
$date->addDay();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use Illuminate\Http\Request;
|
|||
|
||||
class FaqQuestionsController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$questions = FaqQuestions::all();
|
||||
for ($i = 0; $i < count($questions); $i++) {
|
||||
$questions[$i]['toggle'] = false;
|
||||
|
|
@ -26,20 +27,21 @@ class FaqQuestionsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function saveDatas(Request $request) {
|
||||
public function saveDatas(Request $request)
|
||||
{
|
||||
$questions = $request->questions;
|
||||
|
||||
for ($i = 0; $i < count($questions); $i++) {
|
||||
if (isset($questions[$i]["id"])) {
|
||||
$q = FaqQuestions::findOrFail($questions[$i]["id"]);
|
||||
$q->question = $questions[$i]["question"];
|
||||
$q->answer = $questions[$i]["answer"];
|
||||
$q = FaqQuestions::findOrFail($questions[$i]["id"]);
|
||||
$q->question = $questions[$i]["question"];
|
||||
$q->answer = $questions[$i]["answer"];
|
||||
$q->positive_vote = $questions[$i]["positive_vote"];
|
||||
$q->negative_vote = $questions[$i]["negative_vote"];
|
||||
$q->theme_id = $questions[$i]["theme_id"];
|
||||
$q->theme_id = $questions[$i]["theme_id"];
|
||||
$q->save();
|
||||
} else {
|
||||
$t = FaqQuestions::updateOrCreate(
|
||||
$t = FaqQuestions::updateOrCreate(
|
||||
[
|
||||
'question' => $questions[$i]["question"],
|
||||
'answer' => $questions[$i]["answer"],
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use Illuminate\Http\Request;
|
|||
|
||||
class FaqThemesController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$themes = FaqThemes::all();
|
||||
return view('bo.faq-themes.index', compact('themes'));
|
||||
}
|
||||
|
|
@ -20,7 +21,7 @@ class FaqThemesController extends Controller
|
|||
|
||||
if (FaqQuestions::where('theme_id', $request->id)->count() > 0) {
|
||||
$deleteOk = 1;
|
||||
} else if ($request->id !== null) {
|
||||
} elseif ($request->id !== null) {
|
||||
$theme = FaqThemes::findOrFail($request->id);
|
||||
$theme->delete();
|
||||
} else {
|
||||
|
|
@ -30,16 +31,17 @@ class FaqThemesController extends Controller
|
|||
return $deleteOk;
|
||||
}
|
||||
|
||||
public function saveDatas(Request $request) {
|
||||
public function saveDatas(Request $request)
|
||||
{
|
||||
$themes = $request->themes;
|
||||
|
||||
for ($i = 0; $i < count($themes); $i++) {
|
||||
if (isset($themes[$i]["id"])) {
|
||||
$t = FaqThemes::findOrFail($themes[$i]["id"]);
|
||||
$t = FaqThemes::findOrFail($themes[$i]["id"]);
|
||||
$t->name = $themes[$i]["name"];
|
||||
$t->save();
|
||||
} else {
|
||||
$t = FaqThemes::updateOrCreate(['name' => $themes[$i]["name"]]);
|
||||
$t = FaqThemes::updateOrCreate(['name' => $themes[$i]["name"]]);
|
||||
$themes[$i]["id"] = $t->id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace App\Http\Controllers\bo;
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\GainView;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GainViewController extends Controller
|
||||
|
|
@ -27,17 +26,18 @@ class GainViewController extends Controller
|
|||
return $retour;
|
||||
}
|
||||
|
||||
public function saveDatas(Request $request) {
|
||||
public function saveDatas(Request $request)
|
||||
{
|
||||
$gv = $request->gainViews;
|
||||
|
||||
for ($i = 0; $i < count($gv); $i++) {
|
||||
if (isset($gv[$i]["id"])) {
|
||||
$g = GainView::findOrFail($gv[$i]["id"]);
|
||||
$g->name = $gv[$i]["name"];
|
||||
$g = GainView::findOrFail($gv[$i]["id"]);
|
||||
$g->name = $gv[$i]["name"];
|
||||
$g->file_name = $gv[$i]["file_name"];
|
||||
$g->save();
|
||||
} else {
|
||||
$g = GainView::updateOrCreate(['name' => $gv[$i]["name"], 'file_name' => $gv[$i]["file_name"]]);
|
||||
$g = GainView::updateOrCreate(['name' => $gv[$i]["name"], 'file_name' => $gv[$i]["file_name"]]);
|
||||
$gv[$i]["id"] = $g->id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ use App\Models\Settings;
|
|||
|
||||
class InstantWinController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$nbInstantWin = InstantWin::count();
|
||||
$canGenerate = 0;
|
||||
$canGenerate = 0;
|
||||
|
||||
if (intval($nbInstantWin) > 0) {
|
||||
$canGenerate = 0;
|
||||
|
|
@ -32,35 +33,39 @@ class InstantWinController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function instantWinGenerate() {
|
||||
public function instantWinGenerate()
|
||||
{
|
||||
$start_date = Settings::latest()->value("start_date");
|
||||
$end_date = Settings::latest()->value("end_date");
|
||||
$lots = Prizes::all();
|
||||
$end_date = Settings::latest()->value("end_date");
|
||||
$lots = Prizes::all();
|
||||
|
||||
|
||||
|
||||
$begin = new \DateTime( $start_date );
|
||||
$end = new \DateTime( $end_date );
|
||||
$interval = new \DateInterval('P1D');
|
||||
$daterange = new \DatePeriod($begin, $interval ,$end);
|
||||
$begin = new \DateTime($start_date);
|
||||
$end = new \DateTime($end_date);
|
||||
$interval = new \DateInterval('P1D');
|
||||
$daterange = new \DatePeriod($begin, $interval, $end);
|
||||
$dateGlobal = [];
|
||||
$lotsGlobal = [];
|
||||
|
||||
|
||||
|
||||
foreach ($lots as $k => $lot)
|
||||
for ($i = 0; $i < $lot->quantity; $i++)
|
||||
foreach ($lots as $k => $lot) {
|
||||
for ($i = 0; $i < $lot->quantity; $i++) {
|
||||
$lotsGlobal[] = ['id' => $lot->id, 'name' => $lot->label_one, 'hour' => str_pad(mt_rand(6, 22), 2, "0", STR_PAD_LEFT) . ":" . str_pad(mt_rand(0, 59), 2, "0", STR_PAD_LEFT) . ":00"];
|
||||
}
|
||||
}
|
||||
shuffle($lotsGlobal);
|
||||
foreach($daterange as $date)
|
||||
foreach ($daterange as $date) {
|
||||
array_push($dateGlobal, ['date' => $date->format("Y-m-d"), 'lots' => []]);
|
||||
}
|
||||
|
||||
$res = $this->generate($lotsGlobal,$dateGlobal, 0);
|
||||
$res = $this->generate($lotsGlobal, $dateGlobal, 0);
|
||||
|
||||
foreach ($res as $date) {
|
||||
foreach ($date['lots'] as $lot) {
|
||||
$iw = new InstantWin();
|
||||
$iw->prize_id = $lot['id'];
|
||||
$iw = new InstantWin();
|
||||
$iw->prize_id = $lot['id'];
|
||||
$iw->appear_date = date('Y-m-d H:i:s', strtotime($date['date'] . " " . $lot['hour']));
|
||||
$iw->save();
|
||||
}
|
||||
|
|
@ -72,7 +77,8 @@ class InstantWinController extends Controller
|
|||
|
||||
|
||||
|
||||
private function generate($lotsGlobal, $dateGlobal, $lotsDone){
|
||||
private function generate($lotsGlobal, $dateGlobal, $lotsDone)
|
||||
{
|
||||
$rKey = array_rand($dateGlobal, 1);
|
||||
if ($lotsDone < count($dateGlobal)) {
|
||||
if (count($dateGlobal[$rKey]['lots']) > 0) {
|
||||
|
|
@ -83,14 +89,16 @@ class InstantWinController extends Controller
|
|||
if ($lotsDone < count($lotsGlobal)) {
|
||||
return $this->generate($lotsGlobal, $dateGlobal, $lotsDone);
|
||||
}
|
||||
foreach ($dateGlobal as $k => $date)
|
||||
foreach ($dateGlobal as $k => $date) {
|
||||
usort($dateGlobal[$k]['lots'], [$this, 'sortFunction']);
|
||||
}
|
||||
return $dateGlobal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function sortFunction( $a, $b ) {
|
||||
private function sortFunction($a, $b)
|
||||
{
|
||||
return strtotime($a["hour"]) - strtotime($b["hour"]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,17 @@ use Illuminate\Support\Str;
|
|||
|
||||
class PrizesController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
$prizes = Prizes::all();
|
||||
public function index()
|
||||
{
|
||||
$prizes = Prizes::all();
|
||||
$gainViews = GainView::all();
|
||||
return view('bo.prizes.index', compact('prizes', 'gainViews'));
|
||||
}
|
||||
|
||||
public function saveDatas(Request $request) {
|
||||
public function saveDatas(Request $request)
|
||||
{
|
||||
$prizes = json_decode($request->prizes);
|
||||
$pdfs = $request->file('pdf');
|
||||
$pdfs = $request->file('pdf');
|
||||
|
||||
try {
|
||||
$request->validate([
|
||||
|
|
@ -31,17 +33,17 @@ class PrizesController extends Controller
|
|||
if ($prize->id !== null) {
|
||||
$p = Prizes::findOrFail($prize->id);
|
||||
|
||||
$p->arcadia_id = $prize->arcadia_id;
|
||||
$p->label_one = $prize->label_one;
|
||||
$p->label_many = $prize->label_many;
|
||||
$p->quantity = $prize->quantity;
|
||||
$p->arcadia_id = $prize->arcadia_id;
|
||||
$p->label_one = $prize->label_one;
|
||||
$p->label_many = $prize->label_many;
|
||||
$p->quantity = $prize->quantity;
|
||||
$p->arcadia_operation_code = $prize->arcadia_operation_code;
|
||||
$p->arcadia_support_code = $prize->arcadia_support_code;
|
||||
$p->need_proof = $prize->need_proof;
|
||||
$p->gain_view_id = $prize->gain_view_id;
|
||||
$p->arcadia_support_code = $prize->arcadia_support_code;
|
||||
$p->need_proof = $prize->need_proof;
|
||||
$p->gain_view_id = $prize->gain_view_id;
|
||||
|
||||
if (isset($pdfs[$i])) {
|
||||
$fileName = Str::slug($prize->label_one) . '-' . date('d-m-Y') . '.' . $pdfs[$i]->extension();
|
||||
$fileName = Str::slug($prize->label_one) . '-' . date('d-m-Y') . '.' . $pdfs[$i]->extension();
|
||||
$p->pdf_winning_proof = $fileName;
|
||||
$pdfs[$i]->move(public_path('fichiers/pdf/'), $fileName);
|
||||
$prizes[$i]->pdf_winning_proof = $fileName;
|
||||
|
|
@ -49,18 +51,18 @@ class PrizesController extends Controller
|
|||
|
||||
$p->save();
|
||||
} else {
|
||||
$p = new Prizes();
|
||||
$p->arcadia_id = $prize->arcadia_id;
|
||||
$p->label_one = $prize->label_one;
|
||||
$p->label_many = $prize->label_many;
|
||||
$p->quantity = $prize->quantity;
|
||||
$p = new Prizes();
|
||||
$p->arcadia_id = $prize->arcadia_id;
|
||||
$p->label_one = $prize->label_one;
|
||||
$p->label_many = $prize->label_many;
|
||||
$p->quantity = $prize->quantity;
|
||||
$p->arcadia_operation_code = $prize->arcadia_operation_code;
|
||||
$p->arcadia_support_code = $prize->arcadia_support_code;
|
||||
$p->need_proof = $prize->need_proof;
|
||||
$p->gain_view_id = $prize->gain_view_id;
|
||||
$p->arcadia_support_code = $prize->arcadia_support_code;
|
||||
$p->need_proof = $prize->need_proof;
|
||||
$p->gain_view_id = $prize->gain_view_id;
|
||||
|
||||
if (isset($pdfs[$i])) {
|
||||
$fileName = Str::slug($prize->label_one) . '-' . date('d-m-Y') . '.' . $pdfs[$i]->extension();
|
||||
$fileName = Str::slug($prize->label_one) . '-' . date('d-m-Y') . '.' . $pdfs[$i]->extension();
|
||||
$p->pdf_winning_proof = $fileName;
|
||||
$pdfs[$i]->move(public_path('fichiers/pdf/'), $fileName);
|
||||
$prizes[$i]->pdf_winning_proof = $fileName;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
namespace App\Http\Controllers\bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StoreProductRequest;
|
||||
use App\Http\Requests\UpdateProductRequest;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Range;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ProductsController extends Controller
|
||||
|
|
@ -27,32 +29,34 @@ class ProductsController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('bo.products.create');
|
||||
$ranges = Range::all();
|
||||
if (!count($ranges)) {
|
||||
return \redirect()->route('bo.ranges.index')
|
||||
->with(
|
||||
'error',
|
||||
'Vous devez ajouter une gamme avant de pouvoir ajouter un produit'
|
||||
);
|
||||
}
|
||||
return view('bo.products.create', compact('ranges'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Http\Requests\StoreProductRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store(StoreProductRequest $request)
|
||||
{
|
||||
$name = $request->name;
|
||||
$slug = Str::slug($name);
|
||||
$no_art = $request->no_art;
|
||||
$name = $request->name;
|
||||
$slug = Str::slug($name);
|
||||
$no_art = $request->no_art;
|
||||
$picture = $request->picture;
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'picture' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:' .
|
||||
'max-width=500' .
|
||||
',max-height=500',
|
||||
]);
|
||||
|
||||
$product = new Product();
|
||||
$product->name = $name;
|
||||
$product = new Product();
|
||||
$product->name = $name;
|
||||
$product->no_art = $no_art;
|
||||
$product->range()->associate($request->range_id);
|
||||
$product->save();
|
||||
|
||||
if ($picture !== null) {
|
||||
|
|
@ -84,45 +88,49 @@ class ProductsController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$ranges = Range::all();
|
||||
if (!count($ranges)) {
|
||||
return \redirect()->route('bo.ranges.index')
|
||||
->with(
|
||||
'error',
|
||||
'Vous devez ajouter une gamme avant de pouvoir ajouter un produit'
|
||||
);
|
||||
}
|
||||
$product = Product::findOrFail($id);
|
||||
return view('bo.products.edit', compact('product'));
|
||||
return view('bo.products.edit', compact('product', 'ranges'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Http\Requests\UpdateProductRequest $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(UpdateProductRequest $request, $id)
|
||||
{
|
||||
$name = $request->name;
|
||||
$slug = Str::slug($name);
|
||||
$no_art = $request->no_art;
|
||||
$name = $request->name;
|
||||
$slug = Str::slug($name);
|
||||
$no_art = $request->no_art;
|
||||
$picture = $request->picture;
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'picture' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:' .
|
||||
'max-width=500' .
|
||||
',max-height=500',
|
||||
]);
|
||||
|
||||
$product = Product::findOrFail($id);
|
||||
$product->range()->associate($request->range_id);
|
||||
|
||||
if ($picture !== null) {
|
||||
if ($product->picture !== null && file_exists(public_path('images/produits/') . $product->picture))
|
||||
if ($product->picture !== null && file_exists(public_path('images/produits/') . $product->picture)) {
|
||||
unlink(public_path('images/produits/') . $product->picture);
|
||||
}
|
||||
$imageName = $product->id . '_' . $slug . '_' . Str::random(5) . '.' . $picture->extension();
|
||||
$picture->move(public_path('images/produits'), $imageName);
|
||||
}
|
||||
|
||||
$product->name = $name;
|
||||
$product->name = $name;
|
||||
$product->no_art = $no_art;
|
||||
|
||||
if ($picture !== null)
|
||||
if ($picture !== null) {
|
||||
$product->picture = $imageName;
|
||||
}
|
||||
$product->save();
|
||||
|
||||
return redirect()->route('bo.products.edit', $product->id)->with('success', 'Modifications enregistrés !');
|
||||
|
|
|
|||
106
app/Http/Controllers/bo/RangeController.php
Normal file
106
app/Http/Controllers/bo/RangeController.php
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StoreRangeRequest;
|
||||
use App\Http\Requests\UpdateRangeRequest;
|
||||
use App\Models\Range;
|
||||
|
||||
class RangeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$ranges = Range::paginate();
|
||||
return view('bo.ranges.index', compact('ranges'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('bo.ranges.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\StoreRangeRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(StoreRangeRequest $request)
|
||||
{
|
||||
if (!(new Range($request->validated()))->save()) {
|
||||
return back()->withErrors('Impossible de sauvegarder la gamme');
|
||||
}
|
||||
return \response()->redirectToRoute('bo.ranges.index')
|
||||
->with('success', 'La gamme à bien été enregistré !');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Range $range
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Range $range)
|
||||
{
|
||||
return view('bo.ranges.view', compact('range'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Range $range
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Range $range)
|
||||
{
|
||||
return view('bo.ranges.update', compact('range'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\UpdateRangeRequest $request
|
||||
* @param \App\Models\Range $range
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(UpdateRangeRequest $request, Range $range)
|
||||
{
|
||||
$range->fill($request->validated());
|
||||
$range->saveOrFail();
|
||||
return \response()->redirectToRoute('bo.ranges.edit', $range)
|
||||
->with('success', 'La gamme à bien été mise à jour !');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Range $range
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Range $range)
|
||||
{
|
||||
if ($range->products()->count()) {
|
||||
return back()->withError(
|
||||
'Cette gamme est associé a des produits, la supression n\'est pas possible'
|
||||
);
|
||||
}
|
||||
if (!$range->delete()) {
|
||||
return back()->withError(
|
||||
'Erreur lors de la suppression de la gamme'
|
||||
);
|
||||
}
|
||||
return \response()->redirectToRoute('bo.ranges.index')
|
||||
->with('warning', 'La gamme à bien été supprimée !');
|
||||
}
|
||||
}
|
||||
|
|
@ -15,62 +15,64 @@ class SettingsController extends Controller
|
|||
$settings = Settings::find(1);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
$name = $request->name;
|
||||
$startDate = $request->start_date;
|
||||
$endDate = $request->end_date;
|
||||
$name = $request->name;
|
||||
$startDate = $request->start_date;
|
||||
$endDate = $request->end_date;
|
||||
$nbParticipationPlayer = $request->nb_participation_player;
|
||||
$nbParticipationIp = $request->nb_participation_ip;
|
||||
$nbUniqueCodeUse = $request->nb_unique_code_use;
|
||||
$useEanCodes = $request->use_ean_codes === null ? 0 : 1;
|
||||
$activatedTeaser = $request->activated_teaser === null ? 0 : 1;
|
||||
$teaserEndActivity = $request->teaser_end_activity;
|
||||
$activatedClosePage = $request->activated_close_page === null ? 0 : 1;
|
||||
$closePageActiveDate = $request->close_page_active_date;
|
||||
$redirectClose = $request->redirect_close;
|
||||
$reductionsActivated = $request->reductions_activated === null ? 0 : 1;
|
||||
$reductionsSite = $request->reductions_site;
|
||||
$reductionsCampaign = $request->reductions_campaign;
|
||||
$webCoupons = $request->web_coupons;
|
||||
$facebookActivated = $request->facebook_activated === null ? 0 : 1;
|
||||
$facebookAppId = $request->facebook_app_id;
|
||||
$facebookSecret = $request->facebook_secret;
|
||||
$notificationEmails = $request->notification_emails;
|
||||
$winningProof = $request->winning_proof === null ? 0 : 1;
|
||||
$company = $request->company;
|
||||
$analytics = $request->analytics;
|
||||
$nbParticipationIp = $request->nb_participation_ip;
|
||||
$nbUniqueCodeUse = $request->nb_unique_code_use;
|
||||
$useEanCodes = $request->use_ean_codes === null ? 0 : 1;
|
||||
$activatedTeaser = $request->activated_teaser === null ? 0 : 1;
|
||||
$teaserEndActivity = $request->teaser_end_activity;
|
||||
$activatedClosePage = $request->activated_close_page === null ? 0 : 1;
|
||||
$closePageActiveDate = $request->close_page_active_date;
|
||||
$redirectClose = $request->redirect_close;
|
||||
$reductionsActivated = $request->reductions_activated === null ? 0 : 1;
|
||||
$reductionsSite = $request->reductions_site;
|
||||
$reductionsCampaign = $request->reductions_campaign;
|
||||
$webCoupons = $request->web_coupons;
|
||||
$facebookActivated = $request->facebook_activated === null ? 0 : 1;
|
||||
$facebookAppId = $request->facebook_app_id;
|
||||
$facebookSecret = $request->facebook_secret;
|
||||
$notificationEmails = $request->notification_emails;
|
||||
$winningProof = $request->winning_proof === null ? 0 : 1;
|
||||
$company = $request->company;
|
||||
$analytics = $request->analytics;
|
||||
|
||||
// Check du lien de redirection après fermeture
|
||||
if (strpos($redirectClose, 'https://') === false && strpos($redirectClose, 'http://') === false)
|
||||
if (strpos($redirectClose, 'https://') === false && strpos($redirectClose, 'http://') === false) {
|
||||
$redirectClose = 'https://' . $redirectClose;
|
||||
}
|
||||
|
||||
$settings->name = $name;
|
||||
$settings->start_date = $startDate;
|
||||
$settings->end_date = $endDate;
|
||||
$settings->name = $name;
|
||||
$settings->start_date = $startDate;
|
||||
$settings->end_date = $endDate;
|
||||
$settings->nb_participation_player = $nbParticipationPlayer;
|
||||
$settings->nb_participation_ip = $nbParticipationIp;
|
||||
$settings->nb_unique_code_use = $nbUniqueCodeUse;
|
||||
$settings->use_ean_codes = $useEanCodes;
|
||||
$settings->activated_teaser = $activatedTeaser;
|
||||
if ($activatedTeaser === 1)
|
||||
$settings->nb_participation_ip = $nbParticipationIp;
|
||||
$settings->nb_unique_code_use = $nbUniqueCodeUse;
|
||||
$settings->use_ean_codes = $useEanCodes;
|
||||
$settings->activated_teaser = $activatedTeaser;
|
||||
if ($activatedTeaser === 1) {
|
||||
$settings->teaser_end_activity = Carbon::parse($teaserEndActivity);
|
||||
}
|
||||
$settings->activated_close_page = $activatedClosePage;
|
||||
if ($activatedClosePage === 1)
|
||||
if ($activatedClosePage === 1) {
|
||||
$settings->close_page_active_date = Carbon::parse($closePageActiveDate);
|
||||
$settings->redirect_close = $redirectClose;
|
||||
}
|
||||
$settings->redirect_close = $redirectClose;
|
||||
$settings->reductions_activated = $reductionsActivated;
|
||||
if ($reductionsActivated === 1) {
|
||||
$settings->reductions_site = $reductionsSite;
|
||||
$settings->reductions_site = $reductionsSite;
|
||||
$settings->reductions_campaign = $reductionsCampaign;
|
||||
$settings->web_coupons = $webCoupons;
|
||||
$settings->web_coupons = $webCoupons;
|
||||
}
|
||||
$settings->facebook_activated = $facebookActivated;
|
||||
$settings->facebook_app_id = $facebookAppId;
|
||||
$settings->facebook_secret = $facebookSecret;
|
||||
$settings->facebook_activated = $facebookActivated;
|
||||
$settings->facebook_app_id = $facebookAppId;
|
||||
$settings->facebook_secret = $facebookSecret;
|
||||
$settings->notification_emails = $notificationEmails;
|
||||
$settings->winning_proof = $winningProof;
|
||||
$settings->company = $company;
|
||||
$settings->analytics = $analytics;
|
||||
$settings->winning_proof = $winningProof;
|
||||
$settings->company = $company;
|
||||
$settings->analytics = $analytics;
|
||||
|
||||
$settings->save();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,59 +11,64 @@ use Illuminate\Support\Facades\Mail;
|
|||
|
||||
class WinnersListController extends Controller
|
||||
{
|
||||
|
||||
private $apiCrm;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$winnersList = Participation::where('instant_win_id', '<>', null)->get();
|
||||
$settings = Settings::select('use_ean_codes', 'winning_proof')->first();
|
||||
$settings = Settings::select('use_ean_codes', 'winning_proof')->first();
|
||||
return view('bo.winners-list.index', compact('winnersList', 'settings'));
|
||||
}
|
||||
|
||||
public function courrierArcadia($id) {
|
||||
public function courrierArcadia($id)
|
||||
{
|
||||
$participation = Participation::findOrFail($id);
|
||||
|
||||
$crmUser = $this->apiCrm->getCustomer($participation->user->crm_id);
|
||||
if ($crmUser->status === 'NOK')
|
||||
return back()->withErrors("Erreur lors de la récupération de l'utilisateur dans la CRM : Code : ". $crmUser->code. " Message : " . $crmUser->message);
|
||||
if ($crmUser->status === 'NOK') {
|
||||
return back()->withErrors("Erreur lors de la récupération de l'utilisateur dans la CRM : Code : " . $crmUser->code . " Message : " . $crmUser->message);
|
||||
}
|
||||
|
||||
$crmId = $participation->user->crm_id;
|
||||
|
||||
$crmUser = $crmUser->user;
|
||||
|
||||
$corps = '<arcadia>' . "\n" ;
|
||||
$corps .= '<Commande> ' . "\n" ;
|
||||
$corps .= "\t" . '<Num_Commande></Num_Commande>' . "\n" ;
|
||||
$corps .= "\t" . '<Date_Commande>' . date ('d/m/Y') . '</Date_Commande>' . "\n" ;
|
||||
$corps .= "\t" . '<Operation></Operation> ' . "\n" ;
|
||||
$corps .= "\t" . '<Civilite></Civilite>' . "\n" ;
|
||||
$corps .= "\t" . '<Nom><![CDATA[' .trim ($crmUser->firstname). ']]></Nom>' . "\n" ;
|
||||
$corps .= "\t" . '<Prenom><![CDATA[' .trim ($crmUser->lastname). ']]></Prenom>' . "\n" ;
|
||||
$corps .= "\t" . '<Adresse><![CDATA[' .trim ($crmUser->address). ']]></Adresse>' . "\n" ;
|
||||
$corps .= "\t" . '<Adresse_Complementaire><![CDATA[' .trim ($crmUser->address2). ']]></Adresse_Complementaire>' . "\n" ;
|
||||
$corps .= "\t" . '<CP><![CDATA[' .trim ($crmUser->postcode). ']]></CP>' . "\n" ;
|
||||
$corps .= "\t" . '<Ville><![CDATA[' .trim ($crmUser->city). ']]></Ville>' . "\n" ;
|
||||
$corps .= '<Ligne_de_Commande>' . "\n" ;
|
||||
$corps .= "\t" . '<Code_Support></Code_Support> ' . "\n" ;
|
||||
$corps .= "\t" . '<Libelle_Type_Support></Libelle_Type_Support> ' . "\n" ;
|
||||
$corps .= "\t" . '<Quantite>1</Quantite>' . "\n" ;
|
||||
$corps .= "\t" . '<Poids_Unitaire_Colis></Poids_Unitaire_Colis>' . "\n" ;
|
||||
$corps .= '</Ligne_de_Commande>' . "\n" ;
|
||||
$corps .= '</Commande> ' . "\n" ;
|
||||
$corps .= '</arcadia>' ;
|
||||
$corps = '<arcadia>' . "\n";
|
||||
$corps .= '<Commande> ' . "\n";
|
||||
$corps .= "\t" . '<Num_Commande></Num_Commande>' . "\n";
|
||||
$corps .= "\t" . '<Date_Commande>' . date('d/m/Y') . '</Date_Commande>' . "\n";
|
||||
$corps .= "\t" . '<Operation></Operation> ' . "\n";
|
||||
$corps .= "\t" . '<Civilite></Civilite>' . "\n";
|
||||
$corps .= "\t" . '<Nom><![CDATA[' . trim($crmUser->firstname) . ']]></Nom>' . "\n";
|
||||
$corps .= "\t" . '<Prenom><![CDATA[' . trim($crmUser->lastname) . ']]></Prenom>' . "\n";
|
||||
$corps .= "\t" . '<Adresse><![CDATA[' . trim($crmUser->address) . ']]></Adresse>' . "\n";
|
||||
$corps .= "\t" . '<Adresse_Complementaire><![CDATA[' . trim($crmUser->address2) . ']]></Adresse_Complementaire>' . "\n";
|
||||
$corps .= "\t" . '<CP><![CDATA[' . trim($crmUser->postcode) . ']]></CP>' . "\n";
|
||||
$corps .= "\t" . '<Ville><![CDATA[' . trim($crmUser->city) . ']]></Ville>' . "\n";
|
||||
$corps .= '<Ligne_de_Commande>' . "\n";
|
||||
$corps .= "\t" . '<Code_Support></Code_Support> ' . "\n";
|
||||
$corps .= "\t" . '<Libelle_Type_Support></Libelle_Type_Support> ' . "\n";
|
||||
$corps .= "\t" . '<Quantite>1</Quantite>' . "\n";
|
||||
$corps .= "\t" . '<Poids_Unitaire_Colis></Poids_Unitaire_Colis>' . "\n";
|
||||
$corps .= '</Ligne_de_Commande>' . "\n";
|
||||
$corps .= '</Commande> ' . "\n";
|
||||
$corps .= '</arcadia>';
|
||||
|
||||
return view('bo.winners-list.arcadia', compact('participation', 'corps', 'crmId'));
|
||||
}
|
||||
|
||||
public function createCourrierArcadia(Request $request, $id) {
|
||||
public function createCourrierArcadia(Request $request, $id)
|
||||
{
|
||||
$participation = Participation::findOrFail($id);
|
||||
$instantWin = $participation->instant_win;
|
||||
$instantWin = $participation->instant_win;
|
||||
|
||||
if ($instantWin->prize->arcadia_operation_code !== 0 && $instantWin->prize->arcadia_support_code !== 0) {
|
||||
|
||||
$fields = [
|
||||
'root' => [
|
||||
[
|
||||
|
|
@ -100,9 +105,9 @@ class WinnersListController extends Controller
|
|||
}
|
||||
|
||||
$arcadiaMail = $this->apiCrm->ArcadiaOutgoingMail($participation->user->crm_id, $fields, 'game');
|
||||
if ($arcadiaMail->status === 'NOK'){
|
||||
if ($arcadiaMail->status === 'NOK') {
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new CourrierArcadiaError($participation->user));
|
||||
return back()->withErrors("Erreur lors de l'envoi du courrier Arcadia. Code : ". $arcadiaMail->code. " Message : " . $arcadiaMail->message);
|
||||
return back()->withErrors("Erreur lors de l'envoi du courrier Arcadia. Code : " . $arcadiaMail->code . " Message : " . $arcadiaMail->message);
|
||||
}
|
||||
}
|
||||
return back()->with('success', 'Courrier envoyé !');
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\Settings;
|
||||
use App\Models\Reductions;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class re7Controller extends Controller
|
||||
{
|
||||
|
|
@ -31,10 +30,10 @@ class re7Controller extends Controller
|
|||
|
||||
public function br()
|
||||
{
|
||||
$settings = Settings::find(1);
|
||||
$coupon = $this->getRandomCoupon($settings);
|
||||
$settings = Settings::find(1);
|
||||
$coupon = $this->getRandomCoupon($settings);
|
||||
$crmCoupon = new Reductions();
|
||||
return view('front.basic.reduction', compact('coupon','crmCoupon'));
|
||||
return view('front.basic.reduction', compact('coupon', 'crmCoupon'));
|
||||
}
|
||||
|
||||
public function gain1()
|
||||
|
|
@ -48,15 +47,19 @@ class re7Controller extends Controller
|
|||
}
|
||||
|
||||
|
||||
private function getRandomCoupon($settings) {
|
||||
private function getRandomCoupon($settings)
|
||||
{
|
||||
$webCoupons = json_decode($settings->web_coupons);
|
||||
if (count($webCoupons) > 1) {
|
||||
$lots = [];
|
||||
foreach($webCoupons as $webCoupon)
|
||||
foreach ($webCoupons as $webCoupon) {
|
||||
$lots[] = $webCoupon;
|
||||
foreach ($lots as $lot)
|
||||
for ($i = 0; $i < $lot->percentage; $i++)
|
||||
}
|
||||
foreach ($lots as $lot) {
|
||||
for ($i = 0; $i < $lot->percentage; $i++) {
|
||||
$tmp[] = $lot;
|
||||
}
|
||||
}
|
||||
shuffle($tmp);
|
||||
return $tmp[0];
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
|||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
|||
|
||||
class CheckForMaintenanceMode extends Middleware
|
||||
{
|
||||
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
|||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -20,15 +20,17 @@ class GameCheckDate
|
|||
|
||||
// Check si le teaser est actif
|
||||
if ($settings->start_date > now()) {
|
||||
if ($settings->activated_teaser === 1 && $settings->teaser_end_activity > now())
|
||||
if ($settings->activated_teaser === 1 && $settings->teaser_end_activity > now()) {
|
||||
return redirect()->route('teaser');
|
||||
}
|
||||
return redirect($settings->redirect_close);
|
||||
}
|
||||
|
||||
// Check si le jeu est terminé
|
||||
if ($settings->end_date < now()) {
|
||||
if ($settings->activated_close_page === 1 && $settings->close_page_active_date > now())
|
||||
if ($settings->activated_close_page === 1 && $settings->close_page_active_date > now()) {
|
||||
return redirect()->route('end');
|
||||
}
|
||||
return redirect($settings->redirect_close);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
|||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Illuminate\Http\Request;
|
|||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
|||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@ class isAdmin
|
|||
public function handle($request, Closure $next)
|
||||
{
|
||||
$role = Auth::user()->role;
|
||||
if ($role === 1 || $role === 2)
|
||||
if ($role === 1 || $role === 2) {
|
||||
return $next($request);
|
||||
}
|
||||
abort(404, "Cette page n'existe pas.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@ class isSuperAdmin
|
|||
public function handle($request, Closure $next)
|
||||
{
|
||||
$role = Auth::user()->role;
|
||||
if ($role === 1)
|
||||
if ($role === 1) {
|
||||
return $next($request);
|
||||
}
|
||||
return redirect()->route('bo.dashboard');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class re7Middleware
|
|||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if(config('app.env') === 'production') {
|
||||
if (config('app.env') === 'production') {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
return $next($request);
|
||||
|
|
|
|||
32
app/Http/Requests/StoreProductRequest.php
Normal file
32
app/Http/Requests/StoreProductRequest.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreProductRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|min:2|max:255',
|
||||
'picture' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:max-width=500,max-height=500',
|
||||
'range_id' => 'exists:ranges,id'
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/StoreRangeRequest.php
Normal file
30
app/Http/Requests/StoreRangeRequest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRangeRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|min:2|max:255'
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/UpdateProductRequest.php
Normal file
32
app/Http/Requests/UpdateProductRequest.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateProductRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|min:2|max:255',
|
||||
'picture' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:max-width=500,max-height=500',
|
||||
'range_id' => 'exists:ranges,id'
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/UpdateRangeRequest.php
Normal file
30
app/Http/Requests/UpdateRangeRequest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRangeRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|min:2|max:255'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,10 @@ use Illuminate\Support\Facades\Mail;
|
|||
|
||||
class ProcessExportCodesUniques implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $nbCodeFic, $nbCodeTot, $nbCodeLigne;
|
||||
|
||||
|
|
@ -27,8 +30,8 @@ class ProcessExportCodesUniques implements ShouldQueue
|
|||
*/
|
||||
public function __construct($nbCodeFic, $nbCodeTot, $nbCodeLigne)
|
||||
{
|
||||
$this->nbCodeFic = $nbCodeFic;
|
||||
$this->nbCodeTot = $nbCodeTot;
|
||||
$this->nbCodeFic = $nbCodeFic;
|
||||
$this->nbCodeTot = $nbCodeTot;
|
||||
$this->nbCodeLigne = $nbCodeLigne;
|
||||
}
|
||||
|
||||
|
|
@ -39,24 +42,26 @@ class ProcessExportCodesUniques implements ShouldQueue
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
$nbCodeFic = $this->nbCodeFic; // Nombre de code par fichier
|
||||
$nbCodeTot = $this->nbCodeTot; // Nombre total de code à exporter
|
||||
$nbCodeFic = $this->nbCodeFic; // Nombre de code par fichier
|
||||
$nbCodeTot = $this->nbCodeTot; // Nombre total de code à exporter
|
||||
$nbCodeLigne = $this->nbCodeLigne; // Nombre de code par ligne
|
||||
|
||||
$totalExportedCodes = 0;
|
||||
$currentFilename = 1;
|
||||
$totalExportedCodes = 0;
|
||||
$currentFilename = 1;
|
||||
$currentExportedCodes = 0;
|
||||
$currentLineCodes = ($nbCodeLigne === 1 ? 1 : 0);
|
||||
$currentLineCodes = ($nbCodeLigne === 1 ? 1 : 0);
|
||||
|
||||
$this->process($nbCodeFic, $nbCodeTot, $nbCodeLigne, $totalExportedCodes, $currentFilename, $currentExportedCodes, $currentLineCodes);
|
||||
|
||||
// Compression des fichiers
|
||||
$zip = new \ZipArchive();
|
||||
if ($zip->open(storage_path('export_codes_uniques/') . "CodesUniques_". date('dmY') .".zip",\ZipArchive::CREATE)===TRUE) {
|
||||
if ($zip->open(storage_path('export_codes_uniques/') . "CodesUniques_" . date('dmY') . ".zip", \ZipArchive::CREATE) === true) {
|
||||
if ($handle = opendir(storage_path('export_codes_uniques/tmp'))) {
|
||||
while (false !== ($file_to_zip = readdir($handle))) {
|
||||
if (pathinfo($file_to_zip,PATHINFO_EXTENSION)!='csv') continue;
|
||||
$zip->addFile(storage_path('export_codes_uniques/tmp/') . $file_to_zip,"$file_to_zip");
|
||||
if (pathinfo($file_to_zip, PATHINFO_EXTENSION) != 'csv') {
|
||||
continue;
|
||||
}
|
||||
$zip->addFile(storage_path('export_codes_uniques/tmp/') . $file_to_zip, "$file_to_zip");
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
|
@ -66,7 +71,9 @@ class ProcessExportCodesUniques implements ShouldQueue
|
|||
// On vide le dossier temporaire des fichiers csv
|
||||
if ($handle = opendir(storage_path('export_codes_uniques/tmp'))) {
|
||||
while (false !== ($file_to_zip = readdir($handle))) {
|
||||
if (pathinfo($file_to_zip,PATHINFO_EXTENSION)!='csv') continue;
|
||||
if (pathinfo($file_to_zip, PATHINFO_EXTENSION) != 'csv') {
|
||||
continue;
|
||||
}
|
||||
unlink(storage_path('export_codes_uniques/tmp/') . $file_to_zip);
|
||||
}
|
||||
closedir($handle);
|
||||
|
|
@ -76,22 +83,23 @@ class ProcessExportCodesUniques implements ShouldQueue
|
|||
Mail::to(config('mail.MAIL_ADMIN'))->send(new ExportCodesUniques(Settings::find(1)->name, $nbCodeFic, $nbCodeTot, $nbCodeLigne));
|
||||
}
|
||||
|
||||
private function process($nbCodeFic, $nbCodeTot, $nbCodeLigne, $totalExportedCodes, $currentFilename, $currentExportedCodes, $currentLineCodes, $lastExportedCodeId = null){
|
||||
private function process($nbCodeFic, $nbCodeTot, $nbCodeLigne, $totalExportedCodes, $currentFilename, $currentExportedCodes, $currentLineCodes, $lastExportedCodeId = null)
|
||||
{
|
||||
$paginate = config('codes.paginate');
|
||||
|
||||
if ($nbCodeTot < $paginate){
|
||||
if ($nbCodeTot < $paginate) {
|
||||
$nbCodeToRetrieve = $nbCodeTot;
|
||||
}else{
|
||||
if ($totalExportedCodes + $paginate > $nbCodeTot){
|
||||
} else {
|
||||
if ($totalExportedCodes + $paginate > $nbCodeTot) {
|
||||
$nbCodeToRetrieve = $nbCodeTot - $totalExportedCodes;
|
||||
}else{
|
||||
} else {
|
||||
$nbCodeToRetrieve = $paginate;
|
||||
}
|
||||
}
|
||||
|
||||
if ($lastExportedCodeId === null) {
|
||||
$codes = Codes::where('code_exported', 0)->take($nbCodeToRetrieve)->get();
|
||||
}else{
|
||||
} else {
|
||||
$codes = Codes::where([
|
||||
['code_exported', '=', 0],
|
||||
['id', '>', $lastExportedCodeId]
|
||||
|
|
@ -102,14 +110,14 @@ class ProcessExportCodesUniques implements ShouldQueue
|
|||
|
||||
$exportedCodesId = [];
|
||||
|
||||
foreach ($codes as $k => $code){
|
||||
if ($currentExportedCodes < $nbCodeTot){
|
||||
if ($currentLineCodes === ($nbCodeLigne === 1 ? 1 : $nbCodeLigne - 1)){
|
||||
foreach ($codes as $k => $code) {
|
||||
if ($currentExportedCodes < $nbCodeTot) {
|
||||
if ($currentLineCodes === ($nbCodeLigne === 1 ? 1 : $nbCodeLigne - 1)) {
|
||||
file_put_contents(storage_path('export_codes_uniques/tmp/') . $currentFilename . ".csv", $code->code_unique . PHP_EOL, FILE_APPEND);
|
||||
$totalExportedCodes++;
|
||||
$currentExportedCodes++;
|
||||
$currentLineCodes = ($nbCodeLigne === 1 ? 1 : 0);
|
||||
}else{
|
||||
} else {
|
||||
file_put_contents(storage_path('export_codes_uniques/tmp/') . $currentFilename . ".csv", $code->code_unique . ";", FILE_APPEND);
|
||||
$totalExportedCodes++;
|
||||
$currentExportedCodes++;
|
||||
|
|
@ -123,18 +131,19 @@ class ProcessExportCodesUniques implements ShouldQueue
|
|||
$currentFilename++;
|
||||
$currentExportedCodes = 0;
|
||||
}
|
||||
if ((($k + 1) === $countCodes) && $totalExportedCodes < $nbCodeTot){
|
||||
if ((($k + 1) === $countCodes) && $totalExportedCodes < $nbCodeTot) {
|
||||
Codes::whereIn('id', $exportedCodesId)->update(['code_exported' => 1]);
|
||||
return $this->process($nbCodeFic, $nbCodeTot, $nbCodeLigne, $totalExportedCodes, $currentFilename, $currentExportedCodes, $currentLineCodes, $lastExportedCodeId);
|
||||
}
|
||||
if (($k + 1) === $countCodes){
|
||||
if (($k + 1) === $countCodes) {
|
||||
Codes::whereIn('id', $exportedCodesId)->update(['code_exported' => 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function failed(Exception $exception) {
|
||||
public function failed(Exception $exception)
|
||||
{
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new JobFailed("ProcessExportCodeUnique", ['message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,15 @@ use Illuminate\Support\Facades\Mail;
|
|||
|
||||
class ProcessUniqueCode implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $quantity;
|
||||
|
||||
private $length;
|
||||
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
|
|
@ -26,9 +31,10 @@ class ProcessUniqueCode implements ShouldQueue
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($quantity, $length, $settings) {
|
||||
public function __construct($quantity, $length, $settings)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
$this->length = $length;
|
||||
$this->length = $length;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
|
|
@ -42,15 +48,15 @@ class ProcessUniqueCode implements ShouldQueue
|
|||
set_time_limit(0);
|
||||
for ($ib = 1; $ib <= $this->quantity;) {
|
||||
try {
|
||||
$code = new Codes();
|
||||
$code->code_unique = $this->getCode($this->length);
|
||||
$code = new Codes();
|
||||
$code->code_unique = $this->getCode($this->length);
|
||||
$code->date_creation = now();
|
||||
$code->save();
|
||||
if ($code){
|
||||
if ($code) {
|
||||
$ib++;
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
if (!strpos($e->getMessage(), 'Duplicate entry')){
|
||||
if (!strpos($e->getMessage(), 'Duplicate entry')) {
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new JobFailed("ProcessUniqueCode", ['message' => $e->getMessage(), 'trace' => $e->getTraceAsString()]));
|
||||
die();
|
||||
}
|
||||
|
|
@ -60,14 +66,15 @@ class ProcessUniqueCode implements ShouldQueue
|
|||
Mail::to(config('mail.MAIL_ADMIN'))->send(new CodeGenerationEnd($this->quantity, $this->settings));
|
||||
}
|
||||
|
||||
private function getCode($car){
|
||||
$chaine = "ABCDEFGHJKMNPQRSTUWXYZ123456789"; // Caractères autorisés
|
||||
private function getCode($car)
|
||||
{
|
||||
$chaine = "ABCDEFGHJKMNPQRSTUWXYZ123456789"; // Caractères autorisés
|
||||
$valprec = "";
|
||||
$string = "";
|
||||
$string = "";
|
||||
srand();
|
||||
for ($i = 0; $i < $car;) {
|
||||
$val = $chaine[rand() % strlen($chaine)];
|
||||
if ($val != $valprec){
|
||||
if ($val != $valprec) {
|
||||
$string .= $val;
|
||||
$valprec = $val;
|
||||
$i++;
|
||||
|
|
@ -76,7 +83,8 @@ class ProcessUniqueCode implements ShouldQueue
|
|||
return $string;
|
||||
}
|
||||
|
||||
public function failed(Exception $exception) {
|
||||
public function failed(Exception $exception)
|
||||
{
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new JobFailed("ProcessUniqueCode", ['message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CodeGenerationEnd extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $quantity;
|
||||
/**
|
||||
|
|
@ -17,7 +17,8 @@ class CodeGenerationEnd extends Mailable
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($quantity, $settings) {
|
||||
public function __construct($quantity, $settings)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use Illuminate\Queue\SerializesModels;
|
|||
|
||||
class CourrierArcadiaError extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $user;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use Illuminate\Queue\SerializesModels;
|
|||
|
||||
class ExportCodesUniques extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $name, $nbCodeFic, $nbCodeTot, $nbCodeLigne;
|
||||
|
||||
|
|
@ -20,9 +21,9 @@ class ExportCodesUniques extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function __construct($name, $nbCodeFic, $nbCodeTot, $nbCodeLigne)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->nbCodeFic = $nbCodeFic;
|
||||
$this->nbCodeTot = $nbCodeTot;
|
||||
$this->name = $name;
|
||||
$this->nbCodeFic = $nbCodeFic;
|
||||
$this->nbCodeTot = $nbCodeTot;
|
||||
$this->nbCodeLigne = $nbCodeLigne;
|
||||
}
|
||||
|
||||
|
|
@ -33,8 +34,8 @@ class ExportCodesUniques extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function build()
|
||||
{
|
||||
$nbCodeFic = $this->nbCodeFic;
|
||||
$nbCodeTot = $this->nbCodeTot;
|
||||
$nbCodeFic = $this->nbCodeFic;
|
||||
$nbCodeTot = $this->nbCodeTot;
|
||||
$nbCodeLigne = $this->nbCodeLigne;
|
||||
return $this->subject("Fin de l'export des codes uniques pour " . $this->name)
|
||||
->view('bo.mails.export-codes-unique-email', compact('nbCodeFic', 'nbCodeTot', 'nbCodeLigne'));
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class JobFailed extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
public $job;
|
||||
|
||||
public $exception;
|
||||
/**
|
||||
* Create a new message instance.
|
||||
|
|
@ -15,7 +21,7 @@ class JobFailed extends Mailable
|
|||
*/
|
||||
public function __construct($job, $exception)
|
||||
{
|
||||
$this->job = $job;
|
||||
$this->job = $job;
|
||||
$this->exception = $exception;
|
||||
}
|
||||
/**
|
||||
|
|
@ -23,7 +29,8 @@ class JobFailed extends Mailable
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build() {
|
||||
public function build()
|
||||
{
|
||||
return $this->subject('[JOB FAILED] Une erreur est survenue pendant le job : ' . $this->job)->view('bo.mails.job-failed');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use Illuminate\Queue\SerializesModels;
|
|||
|
||||
class NotifAdmin extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $msg;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use Illuminate\Queue\SerializesModels;
|
|||
|
||||
class NotifWinAdmin extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $settings, $participation;
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ class NotifWinAdmin extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function __construct($settings, $participation)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->settings = $settings;
|
||||
$this->participation = $participation;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use Illuminate\Queue\SerializesModels;
|
|||
|
||||
class PasswordReset extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected $user, $settings;
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ class PasswordReset extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function __construct($user, $settings)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->user = $user;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use Illuminate\Queue\SerializesModels;
|
|||
|
||||
class PrizeWon extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $user, $prize, $settings;
|
||||
|
||||
|
|
@ -20,8 +21,8 @@ class PrizeWon extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function __construct($user, $prize, $settings)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->prize = $prize;
|
||||
$this->user = $user;
|
||||
$this->prize = $prize;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use Illuminate\Queue\SerializesModels;
|
|||
|
||||
class ReductionWon extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $user, $coupon, $settings, $crmCoupon;
|
||||
|
||||
|
|
@ -20,9 +21,9 @@ class ReductionWon extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function __construct($user, $coupon, $settings, $crmCoupon)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->coupon = $coupon;
|
||||
$this->settings = $settings;
|
||||
$this->user = $user;
|
||||
$this->coupon = $coupon;
|
||||
$this->settings = $settings;
|
||||
$this->crmCoupon = $crmCoupon;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class VerifyEmail extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected $user;
|
||||
|
||||
|
|
@ -30,7 +29,8 @@ class VerifyEmail extends Mailable implements ShouldQueue
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build() {
|
||||
public function build()
|
||||
{
|
||||
return $this->subject("Activation du compte")->view('front.basic.verifyemail')->with('user', $this->user);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Mail;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
|
|
@ -10,7 +9,8 @@ use Illuminate\Queue\SerializesModels;
|
|||
|
||||
class WinningProof extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $sticker, $ticket, $barcode, $participation, $user, $settings;
|
||||
|
||||
|
|
@ -21,12 +21,12 @@ class WinningProof extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function __construct($sticker, $ticket, $barcode, $participation, $user, $settings)
|
||||
{
|
||||
$this->sticker = $sticker;
|
||||
$this->ticket = $ticket;
|
||||
$this->barcode = $barcode;
|
||||
$this->sticker = $sticker;
|
||||
$this->ticket = $ticket;
|
||||
$this->barcode = $barcode;
|
||||
$this->participation = $participation;
|
||||
$this->user = $user;
|
||||
$this->settings = $settings;
|
||||
$this->user = $user;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +37,7 @@ class WinningProof extends Mailable implements ShouldQueue
|
|||
public function build()
|
||||
{
|
||||
$participation = $this->participation;
|
||||
$user = $this->user;
|
||||
$user = $this->user;
|
||||
return $this->subject($this->settings->name . " : Preuves de gain de " . $this->user->lastname . " " . $this->user->firstname)
|
||||
->view('front.basic.winning-proof-email', compact('participation', 'user'))->attach($this->sticker)->attach($this->ticket)->attach($this->barcode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class BannedIP extends Model
|
||||
{
|
||||
|
||||
protected $table = "banned_ip";
|
||||
|
||||
protected $fillable = ['ip'];
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,13 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Codes extends Model
|
||||
{
|
||||
|
||||
protected $fillable = ['code_unique', 'code_used', 'code_exported', 'date_creation'];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function participations() {
|
||||
public function participations()
|
||||
{
|
||||
return $this->hasMany('App\Models\Participation', 'code_unique_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,15 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class CodesEAN extends Model
|
||||
{
|
||||
|
||||
protected $table = "codes_ean";
|
||||
|
||||
protected $fillable = ['code', 'product'];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function participations() {
|
||||
public function participations()
|
||||
{
|
||||
return $this->hasMany('App\Models\Participation', 'code_ean_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Content extends Model
|
||||
{
|
||||
|
||||
protected $table = "content";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,18 +6,22 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class FaqQuestions extends Model
|
||||
{
|
||||
|
||||
protected $table = "faq_questions";
|
||||
|
||||
protected $fillable = ["question", "answer", "positive_vote", "negative_vote", "theme_id"];
|
||||
|
||||
public function theme() {
|
||||
public function theme()
|
||||
{
|
||||
return $this->belongsTo('App\Models\FaqThemes', 'theme_id');
|
||||
}
|
||||
|
||||
public function getUtilityAttribute() {
|
||||
public function getUtilityAttribute()
|
||||
{
|
||||
$pourcent = 0;
|
||||
|
||||
if ($this->positive_vote !== null && $this->negative_vote !== null && $this->positive_vote >= $this->negative_vote && $this->positive_vote > 0 && $this->negative_vote > 0) {
|
||||
$ratio = $this->negative_vote / $this->positive_vote;
|
||||
$ratio = $this->negative_vote / $this->positive_vote;
|
||||
$pourcent = ceil((1 - $ratio) * 100);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,15 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class FaqThemes extends Model
|
||||
{
|
||||
|
||||
protected $table = "faq_themes";
|
||||
|
||||
protected $fillable = ["name"];
|
||||
|
||||
protected $with = ['questions'];
|
||||
|
||||
public function questions() {
|
||||
public function questions()
|
||||
{
|
||||
return $this->hasMany('App\Models\FaqQuestions', 'theme_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class GainView extends Model
|
||||
{
|
||||
|
||||
protected $fillable = ["name", "file_name"];
|
||||
|
||||
public function prizes() {
|
||||
public function prizes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Prizes', 'gain_view_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,15 +6,20 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class InstantWin extends Model
|
||||
{
|
||||
|
||||
protected $table = "instant_win";
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $with = ['prize'];
|
||||
|
||||
public function prize() {
|
||||
public function prize()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Prizes', 'prize_id');
|
||||
}
|
||||
|
||||
public function participation() {
|
||||
public function participation()
|
||||
{
|
||||
return $this->hasOne('App\Models\Participation', 'instant_win_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,29 +6,36 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Participation extends Model
|
||||
{
|
||||
|
||||
protected $table = "participation";
|
||||
|
||||
public function user() {
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'user_id');
|
||||
}
|
||||
|
||||
public function code() {
|
||||
public function code()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Codes', 'code_unique_id');
|
||||
}
|
||||
|
||||
public function code_ean() {
|
||||
public function code_ean()
|
||||
{
|
||||
return $this->belongsTo('App\Models\CodesEAN', 'code_ean_id');
|
||||
}
|
||||
|
||||
public function instant_win() {
|
||||
public function instant_win()
|
||||
{
|
||||
return $this->hasOne('App\Models\InstantWin', 'participation_id');
|
||||
}
|
||||
|
||||
public function reduction() {
|
||||
public function reduction()
|
||||
{
|
||||
return $this->hasOne('App\Models\Reductions', 'reduction_id');
|
||||
}
|
||||
|
||||
public function getCodeEanValueAttribute() {
|
||||
public function getCodeEanValueAttribute()
|
||||
{
|
||||
$code = CodesEAN::find($this->code_ean_id)->code;
|
||||
return $code;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Prizes extends Model
|
||||
{
|
||||
public function gain_view() {
|
||||
public function gain_view()
|
||||
{
|
||||
return $this->belongsTo('App\Models\GainView', 'gain_view_id');
|
||||
}
|
||||
|
||||
public function instant_wins() {
|
||||
public function instant_wins()
|
||||
{
|
||||
return $this->hasMany('App\Models\InstantWin', 'prize_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Product extends Model
|
||||
{
|
||||
//
|
||||
public function range()
|
||||
{
|
||||
return $this->belongsTo(Range::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16
app/Models/Range.php
Normal file
16
app/Models/Range.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Range extends Model
|
||||
{
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->hasMany(Product::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Reductions extends Model
|
||||
{
|
||||
public function participation() {
|
||||
public function participation()
|
||||
{
|
||||
return $this->hasOne('App\Models\Participation', 'participation_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Settings extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -4,10 +4,7 @@ namespace App\Providers;
|
|||
|
||||
use App\Models\Prizes;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Queue\Events\JobProcessed;
|
||||
use Illuminate\Queue\Events\JobProcessing;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
|
@ -31,7 +28,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
if(config('app.env') !== 'local') {
|
||||
if (config('app.env') !== 'local') {
|
||||
\URL::forceScheme('https');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ namespace App\Providers;
|
|||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Route;
|
|||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ class User extends Authenticatable
|
|||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function participations() {
|
||||
public function participations()
|
||||
{
|
||||
return $this->hasMany('App\Models\Participation', 'user_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
"php": "^7.2.5",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"doctrine/dbal": "^2.3",
|
||||
"fideloper/proxy": "^4.2",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
|
|
@ -20,11 +19,14 @@
|
|||
"laravel/ui": "2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/dbal": "^2.0",
|
||||
"facade/ignition": "^2.0",
|
||||
"fzaninotto/faker": "^1.9.1",
|
||||
"mockery/mockery": "^1.3.1",
|
||||
"nunomaduro/collision": "^4.1",
|
||||
"phpunit/phpunit": "^8.5"
|
||||
"phpunit/phpunit": "^8.5",
|
||||
"slevomat/coding-standard": "^7.0",
|
||||
"squizlabs/php_codesniffer": "^3.6"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
|
|
|
|||
7590
composer.lock
generated
Normal file
7590
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -39,7 +39,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
'debug' => (bool)env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -99,6 +99,6 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ return [
|
|||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ return [
|
|||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'url' => env('APP_URL') . '/storage',
|
||||
'visibility' => 'public',
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'endpoint' => env('MESBR_ENDPOINT')
|
||||
];
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ return [
|
|||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_') . '_session'
|
||||
),
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateModelsRangesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('models_ranges', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('models_ranges');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRangesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('ranges', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('ranges');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddRangeIdToProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->foreignId('range_id')->before('created_at')->references('id')
|
||||
->on('ranges')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropForeign(['range_id']);
|
||||
$table->dropColumn('range_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
91
phpcs.xml
Normal file
91
phpcs.xml
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ruleset name="RealWorld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
|
||||
<arg name="colors" />
|
||||
<arg name="extensions" value="php" />
|
||||
<file>app/</file>
|
||||
<file>config/</file>
|
||||
<file>database/factories</file>
|
||||
<file>routes/</file>
|
||||
<file>tests/</file>
|
||||
<rule ref="PSR1" />
|
||||
<rule ref="PSR12" />
|
||||
|
||||
|
||||
<description>Created with the PHP Coding Standard Generator. http://edorian.github.com/php-coding-standard-generator/
|
||||
</description>
|
||||
<rule ref="Generic.CodeAnalysis.EmptyStatement" />
|
||||
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
|
||||
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall" />
|
||||
<rule ref="Generic.CodeAnalysis.JumbledIncrementer" />
|
||||
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement" />
|
||||
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier" />
|
||||
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter" />
|
||||
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
|
||||
<rule ref="Generic.Commenting.Todo" />
|
||||
<rule ref="Generic.Commenting.Fixme" />
|
||||
<rule ref="Generic.ControlStructures.InlineControlStructure" />
|
||||
<rule ref="Generic.Files.ByteOrderMark" />
|
||||
<rule ref="Generic.Files.LineEndings" />
|
||||
<rule ref="Generic.Files.LineLength" />
|
||||
<rule ref="Generic.Formatting.DisallowMultipleStatements" />
|
||||
<rule ref="Generic.Formatting.MultipleStatementAlignment" />
|
||||
<rule ref="Generic.Formatting.NoSpaceAfterCast" />
|
||||
<rule ref="Generic.Functions.CallTimePassByReference" />
|
||||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing" />
|
||||
<rule ref="Generic.Metrics.CyclomaticComplexity" />
|
||||
<rule ref="Generic.Metrics.NestingLevel" />
|
||||
<rule ref="Generic.NamingConventions.ConstructorName" />
|
||||
<rule ref="Generic.NamingConventions.UpperCaseConstantName" />
|
||||
<rule ref="Generic.NamingConventions.CamelCapsFunctionName" />
|
||||
<rule ref="Generic.PHP.DeprecatedFunctions" />
|
||||
<rule ref="Generic.PHP.DisallowShortOpenTag" />
|
||||
<rule ref="Generic.PHP.ForbiddenFunctions" />
|
||||
<rule ref="Generic.PHP.LowerCaseConstant" />
|
||||
<rule ref="Generic.PHP.NoSilencedErrors" />
|
||||
<rule ref="Generic.Strings.UnnecessaryStringConcat" />
|
||||
<rule ref="Generic.WhiteSpace.DisallowTabIndent" />
|
||||
<rule ref="Generic.WhiteSpace.ScopeIndent" />
|
||||
<rule ref="MySource.PHP.EvalObjectFactory" />
|
||||
<rule ref="MySource.PHP.GetRequestData" />
|
||||
<rule ref="MySource.PHP.AjaxNullComparison" />
|
||||
<rule ref="PEAR.Classes.ClassDeclaration" />
|
||||
<rule ref="PEAR.Commenting.InlineComment" />
|
||||
<rule ref="PSR1.Classes.ClassDeclaration" />
|
||||
<rule ref="PSR1.Files.SideEffects" />
|
||||
<rule ref="Squiz.PHP.CommentedOutCode" />
|
||||
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops" />
|
||||
<rule ref="Squiz.PHP.DiscouragedFunctions">
|
||||
<properties>
|
||||
<property name="error" value="true" />
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Squiz.PHP.Eval" />
|
||||
<rule ref="Squiz.PHP.GlobalKeyword" />
|
||||
<rule ref="Squiz.PHP.Heredoc" />
|
||||
<rule ref="Squiz.PHP.InnerFunctions" />
|
||||
<rule ref="Squiz.PHP.LowercasePHPFunctions" />
|
||||
<rule ref="Squiz.PHP.NonExecutableCode" />
|
||||
<rule ref="Squiz.Scope.MemberVarScope" />
|
||||
<rule ref="Squiz.Scope.MethodScope" />
|
||||
<rule ref="Squiz.Scope.StaticThisUsage" />
|
||||
<rule ref="Squiz.WhiteSpace.MemberVarSpacing" />
|
||||
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
|
||||
<properties>
|
||||
<property name="ignoreNewlines" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
|
||||
<properties>
|
||||
<property name="ignoreNewlines" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing" />
|
||||
<rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
|
||||
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse" />
|
||||
|
||||
|
||||
<!-- For Laravel migrations -->
|
||||
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
|
||||
<exclude-pattern>*/database/migrations/*</exclude-pattern>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
|
@ -20,27 +20,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<div class="form-group">
|
||||
<label for="name">Libelle Produit *</label>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="Libelle Produit" value="{{ old('name') }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="no_art">Code Article</label>
|
||||
<input type="text" id="no_art" name="no_art" class="form-control" placeholder="no_art" value="{{ old('no_art') }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="picture">Image *<small class="text-muted">- JPEG/PNG, 2Mo max. Dimensions {{ Config::get('theme.range_image_maxwidth') }} px par {{ Config::get('theme.range_image_maxheight') }} px</small></label></br>
|
||||
<input type="file" id="picture" name="picture" accept="image/png, image/jpeg">
|
||||
</div>
|
||||
@include('bo.products.input-forms')
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,34 +23,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<div class="form-group">
|
||||
<label for="name">Libelle Produit *</label>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="Libelle Produit" value="{{ old('name', $product->name) }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="no_art">Code Article</label>
|
||||
<input type="text" id="no_art" name="no_art" class="form-control" placeholder="no_art" value="{{ old('no_art', $product->no_art) }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="picture">Image *<small class="text-muted">- JPEG/PNG, 2Mo max. Dimensions {{ Config::get('theme.range_image_maxwidth') }} px par {{ Config::get('theme.range_image_maxheight') }} px</small></label></br>
|
||||
<input type="file" id="picture" name="picture" accept="image/png, image/jpeg">
|
||||
@if ($product->picture !== null)
|
||||
<br/>
|
||||
<br/>
|
||||
<a data-fancybox="gallery" href="{{ asset('/images/produits/' . $product->picture ) }}">
|
||||
<img src="{{ asset('/images/produits/' . $product->picture ) }}" alt="{{$product->name}}" style="max-height: 100px">
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
@include('bo.products.input-forms')
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
<a data-fancybox="gallery" href="{{ asset('/images/produits/' . $product->picture ) }}">
|
||||
<img src="{{ asset('/images/produits/' . $product->picture ) }}" alt="{{$product->name}}" style="max-height: 50px">
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('bo.products.edit', $product->id) }}" class="btn btn-sm btn-primary">Modifier</a>
|
||||
<form action="{{route('bo.products.destroy', $product->id)}}" method="POST" class="d-inline">
|
||||
|
|
|
|||
43
resources/views/bo/products/input-forms.blade.php
Normal file
43
resources/views/bo/products/input-forms.blade.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<div class="form-group">
|
||||
<label for="name">Libelle Produit *</label>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="Libelle Produit" value="{{ old('name', $product->name ?? '') }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="no_art">Code Article</label>
|
||||
<input type="text" id="no_art" name="no_art" class="form-control" placeholder="no_art" value="{{ old('no_art', $product->no_art ?? '') }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="picture">Image *<small class="text-muted">- JPEG/PNG, 2Mo max. Dimensions {{ Config::get('theme.range_image_maxwidth') }} px par {{ Config::get('theme.range_image_maxheight') }} px</small></label></br>
|
||||
<input type="file" id="picture" name="picture" accept="image/png, image/jpeg">
|
||||
@if (isset($product->picture) and $product->picture !== null)
|
||||
<br/>
|
||||
<br/>
|
||||
<a data-fancybox="gallery" href="{{ asset('/images/produits/' . $product->picture ) }}">
|
||||
<img src="{{ asset('/images/produits/' . $product->picture ) }}" alt="{{$product->name}}" style="max-height: 100px">
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<label class="input-group-text" for="range">{{ __('Gamme') }}</label>
|
||||
</div>
|
||||
<select class="custom-select" name="range_id" id="range" required>
|
||||
@if(!isset($product))
|
||||
<option selected disabled value="">{{ __('Selectionnez une gamme') }}</option>
|
||||
@endif
|
||||
@foreach($ranges as $range)
|
||||
<option value="{{ $range->id }}" @if(isset($product) and $product->range_id === $range->id) selected @endif>{{ $range->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
27
resources/views/bo/ranges/create.blade.php
Normal file
27
resources/views/bo/ranges/create.blade.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
@extends('layouts.bo')
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<form action="{{route('bo.ranges.store')}}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<a href="{{route('bo.ranges.index')}}" class="h2 text-decoration-none"><</a>{{ __('Gammes - Ajout') }}
|
||||
</div>
|
||||
<div class="col-md-6 text-center">
|
||||
|
||||
</div>
|
||||
<div class="col-md-3 text-right">
|
||||
<button type="submit" class="btn btn-primary btn-sm text-white float-right">
|
||||
{{_('Enregistrer') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@include('bo.ranges.input-forms')
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
30
resources/views/bo/ranges/edit.blade.php
Normal file
30
resources/views/bo/ranges/edit.blade.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
@extends('layouts.bo')
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<form action="{{route('bo.ranges.update', $range->id)}}" method="POST" enctype="multipart/form-data">
|
||||
@method('PUT')
|
||||
@csrf
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<a href="{{route('bo.ranges.index')}}" class="h2 text-decoration-none"><</a>{{ __('Gammes - Modification') }}
|
||||
</div>
|
||||
<div class="col-md-5 text-center">
|
||||
@if (session('success'))
|
||||
<span class="float-center text-success">{{ session('success') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-md-3 text-right">
|
||||
<button type="submit" class="btn btn-primary btn-sm text-white float-right">
|
||||
{{__('Enregistrer') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@include('bo.ranges.input-forms')
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
53
resources/views/bo/ranges/index.blade.php
Normal file
53
resources/views/bo/ranges/index.blade.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
@extends('layouts.bo')
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
{{ __('Gammes') }}
|
||||
</div>
|
||||
<div class="col-md-6 text-center">
|
||||
|
||||
</div>
|
||||
<div class="col-md-3 text-right">
|
||||
<a class="btn btn-primary btn-sm text-white float-right" href="{{route('bo.ranges.create')}}">
|
||||
{{ __('Ajouter') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<table class="table">
|
||||
<thead class="thead-light">
|
||||
<th scope="col">{{ __('Nom') }}</th>
|
||||
<th scope="col"></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($ranges as $range)
|
||||
<tr>
|
||||
<td>{{$range->name}}</td>
|
||||
<td>
|
||||
<a href="{{ route('bo.ranges.edit', $range->id) }}" class="btn btn-sm btn-primary">{{ __('Modifier') }}</a>
|
||||
<form action="{{route('bo.ranges.destroy', $range->id)}}" method="POST" class="d-inline">
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
<input type="submit" class="btn btn-sm btn-danger" value="{{ __('Supprimer') }}" onclick="return confirm('{{ __('Êtes-vous sûr(e) ?') }}')">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
13
resources/views/bo/ranges/input-forms.blade.php
Normal file
13
resources/views/bo/ranges/input-forms.blade.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<div class="form-group">
|
||||
<label for="name">Nom *</label>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="Nom de la gamme" value="{{ old('name', $range->name ?? '') }}" required>
|
||||
</div>
|
||||
|
|
@ -87,6 +87,7 @@
|
|||
<a class="nav-link" href="{{route('bo.instant-win')}}">Instant gagnants</a>
|
||||
@endsuperadmin
|
||||
<a class="nav-link" href="{{route('bo.codes-ean')}}">Code EAN</a>
|
||||
<a class="nav-link" href="{{route('bo.ranges.index')}}">Gammes</a>
|
||||
<a class="nav-link" href="{{route('bo.products.index')}}">Produits porteurs</a>
|
||||
@superadmin
|
||||
<a class="nav-link" href="#_">Social share</a>
|
||||
|
|
@ -113,6 +114,7 @@
|
|||
</nav>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
@include('modules.flashMessage')
|
||||
@yield('content')
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
54
resources/views/modules/flashMessage.blade.php
Normal file
54
resources/views/modules/flashMessage.blade.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
@if ($message = Session::get('success'))
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@if ($message = Session::get('error'))
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@if ($message = Session::get('warning'))
|
||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@if ($message = Session::get('info'))
|
||||
<div class="alert alert-info alert-dismissible fade show" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
@if ($errors->any())
|
||||
<ul class="list-unstyled">
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue