Customer and User separation
This commit is contained in:
parent
0457681ef8
commit
fbcb8bc5bf
95 changed files with 115954 additions and 1112 deletions
|
|
@ -33,36 +33,18 @@ class CreateAdmin extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
$firstname = null;
|
||||
while (is_null($firstname)) {
|
||||
$name = null;
|
||||
while (is_null($name)) {
|
||||
try {
|
||||
$tmp = $this->ask('What is the firstname?', 'Informatique');
|
||||
$validator = Validator::make(['firstname' => $tmp], [
|
||||
'firstname' => 'required|min:5,max:255'
|
||||
$tmp = $this->ask('What is the name?', 'Equipe Web');
|
||||
$validator = Validator::make(['name' => $tmp], [
|
||||
'name' => 'required|min:5,max:255'
|
||||
]);
|
||||
$validator->validate();
|
||||
$firstname = $tmp;
|
||||
$name = $tmp;
|
||||
} catch (ValidationException $e) {
|
||||
$this->error(sprintf(
|
||||
'Please provide a valid firstname %s',
|
||||
\implode(',', collect($e->errors())->flatten()->all())
|
||||
));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$lastname = null;
|
||||
while (is_null($lastname)) {
|
||||
try {
|
||||
$tmp = $this->ask('What is the lastname?', 'Internet');
|
||||
$validator = Validator::make(['lastname' => $tmp], [
|
||||
'lastname' => 'required|min:5,max:255'
|
||||
]);
|
||||
$validator->validate();
|
||||
$lastname = $tmp;
|
||||
} catch (ValidationException $e) {
|
||||
$this->error(sprintf(
|
||||
'Please provide a valid lastname %s',
|
||||
'Please provide a valid name %s',
|
||||
\implode(',', collect($e->errors())->flatten()->all())
|
||||
));
|
||||
continue;
|
||||
|
|
@ -116,20 +98,11 @@ class CreateAdmin extends Command
|
|||
|
||||
$password = $this->secret('What is the password?');
|
||||
|
||||
$user = new User();
|
||||
$user->firstname = $firstname;
|
||||
$user->lastname = $lastname;
|
||||
$user->birth_date = now();
|
||||
$user->email = $email;
|
||||
$user->password = Hash::make($password);
|
||||
$user->address = "-";
|
||||
$user->town = "Le Mans";
|
||||
$user->postal_code = "72000";
|
||||
$user->country = "France";
|
||||
$user->email_verify_token = "-";
|
||||
$user->email_verified = true;
|
||||
$user->role = $role;
|
||||
|
||||
$user = new User();
|
||||
$user->name = $name;
|
||||
$user->email = $email;
|
||||
$user->password = Hash::make($password);
|
||||
$user->role = $role;
|
||||
$user->saveOrFail();
|
||||
|
||||
$this->info('User created.');
|
||||
|
|
|
|||
39
app/Console/Commands/DeleteNotConfirmedCustomer.php
Normal file
39
app/Console/Commands/DeleteNotConfirmedCustomer.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class DeleteNotConfirmedCustomer extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'customers:deletenc';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Remove customers who have not confirmed their accounts within 24 hours of registration';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$customers = Customer::where([['email_verified', false], ['created_at', '<', Carbon::now()->subDay()]])->get();
|
||||
foreach ($customers as $customer) {
|
||||
$customers->delete();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class DeleteNotConfirmedUser extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'users:deletenc';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Remove users who have not confirmed their accounts within 24 hours of registration';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$users = User::where([['email_verified', 0], ['created_at', '<', Carbon::now()->subDay()]])->get();
|
||||
foreach ($users as $user) {
|
||||
$user->delete();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
41
app/Enums/ContentPageType.php
Normal file
41
app/Enums/ContentPageType.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Kwaadpepper\Enum\BaseEnumRoutable;
|
||||
|
||||
/**
|
||||
* @method static self legals()
|
||||
* @method static self charte()
|
||||
* @method static self reglement()
|
||||
*/
|
||||
final class ContentPageType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
'legals' => 1,
|
||||
'charte' => 2,
|
||||
'reglement' => 3
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
'legals' => trans('Mentions légales'),
|
||||
'charte' => trans('Charte'),
|
||||
'reglement' => trans('Règlement')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
/**
|
||||
* @method static self admin()
|
||||
* @method static self brand()
|
||||
* @method static self customer()
|
||||
*/
|
||||
final class UserRole extends BaseEnumRoutable
|
||||
{
|
||||
|
|
@ -20,8 +19,7 @@ final class UserRole extends BaseEnumRoutable
|
|||
{
|
||||
return [
|
||||
'admin' => 0,
|
||||
'brand' => 1,
|
||||
'customer' => 2
|
||||
'brand' => 1
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -34,8 +32,7 @@ final class UserRole extends BaseEnumRoutable
|
|||
{
|
||||
return [
|
||||
'admin' => trans('enums.admin'),
|
||||
'brand' => trans('enums.brand'),
|
||||
'customer' => trans('enums.customer')
|
||||
'brand' => trans('enums.brand')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Kwaadpepper\ExceptionHandler\Exceptions\ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
|
|
@ -24,4 +26,22 @@ class Handler extends ExceptionHandler
|
|||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception .
|
||||
*/
|
||||
public function report(Throwable $e)
|
||||
{
|
||||
if (\get_class($e) === TokenMismatchException::class) {
|
||||
abort(\request()->routeIs('bo.*') ?
|
||||
response()->redirectToRoute('bo.dashboard') :
|
||||
response()->redirectToRoute('home'));
|
||||
}
|
||||
parent::report($e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,33 +3,50 @@
|
|||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\SaveBannedIpListRequest;
|
||||
use App\Models\BannedIp;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BannedIpController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show banned ips list
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$ips = BannedIp::all();
|
||||
return view('bo.banned-ip.index', compact('ips'));
|
||||
}
|
||||
|
||||
public function saveDatas(Request $request)
|
||||
/**
|
||||
* Ajax save data banned ips
|
||||
*
|
||||
* @param SaveBannedIpListRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function saveDatas(SaveBannedIpListRequest $request)
|
||||
{
|
||||
$ips = $request->ips;
|
||||
/** @var \Illuminate\Support\Collection $ips */
|
||||
$ips = \collect($request->ips);
|
||||
|
||||
for ($i = 0; $i < count($ips); $i++) {
|
||||
if (!empty($ips[$i]["ip"])) {
|
||||
$ip = BannedIp::updateOrCreate(['ip' => $ips[$i]["ip"]]);
|
||||
} else {
|
||||
unset($ips[$i]);
|
||||
$i--;
|
||||
}
|
||||
}
|
||||
// * Delete all
|
||||
BannedIp::query()->delete();
|
||||
|
||||
return $ips;
|
||||
$ips->map(function (string $ip) {
|
||||
(new BannedIp(['ip' => $ip]))->saveOrFail();
|
||||
});
|
||||
|
||||
return \response()->json(BannedIp::all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax destroy ip
|
||||
*
|
||||
* @param Request $request
|
||||
* @return string
|
||||
*/
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$ip = BannedIp::where("ip", $request->ip);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\CodeSearchRequest;
|
||||
use App\Http\Requests\ExportCodesRequest;
|
||||
use App\Http\Requests\GenerateCodesRequest;
|
||||
use App\Http\Requests\Bo\CodeSearchRequest;
|
||||
use App\Http\Requests\Bo\ExportCodesRequest;
|
||||
use App\Http\Requests\Bo\GenerateCodesRequest;
|
||||
use App\Jobs\ProcessExportCodesUniques;
|
||||
use App\Jobs\ProcessUniqueCode;
|
||||
use App\Models\Code;
|
||||
|
|
|
|||
|
|
@ -3,23 +3,37 @@
|
|||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\UpdateContentRequest;
|
||||
use App\Models\Content;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ContentController extends Controller
|
||||
{
|
||||
public function manage($id, Request $request)
|
||||
/**
|
||||
* Manage content
|
||||
*
|
||||
* @param Content $content
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function manage(Content $content)
|
||||
{
|
||||
$content = Content::findOrFail($id);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$value = $request->value;
|
||||
$content->value = $value;
|
||||
$content->save();
|
||||
|
||||
return redirect()->route('bo.content', $content->id)->with('success', 'Enregistré !');
|
||||
}
|
||||
|
||||
return view('bo.content.manage', compact('content'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Content update
|
||||
*
|
||||
* @param UpdateContentRequest $request
|
||||
* @param Content $content
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function manageSubmit(UpdateContentRequest $request, Content $content)
|
||||
{
|
||||
$content->fill($request->validated());
|
||||
if ($content->saveOrFail()) {
|
||||
return redirect()->route('bo.contents.manage', $content)
|
||||
->with('success', 'Enregistré !');
|
||||
}
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,28 +10,34 @@ use Illuminate\Support\Facades\DB;
|
|||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show dashboard page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Pour les stats.
|
||||
$settings = app(Settings::class);
|
||||
$participations = Participation::selectRaw("COUNT(*) AS count, DATE(created_at) AS date")
|
||||
$settings = app(Settings::class);
|
||||
$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();
|
||||
//phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$participationsUniquePerDay = Participation::selectRaw("DISTINCT customer_id AS customer, COUNT(*) AS count, DATE(created_at) AS date")
|
||||
->groupByRaw("DATE(created_at), customer")->get();
|
||||
$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();
|
||||
$participationsUnique = Participation::selectRaw("DISTINCT customer_id AS customer, COUNT(*) AS count")
|
||||
->groupBy("customer")->orderBy("customer")->get();
|
||||
|
||||
// Données calculées à afficher.
|
||||
$totalParticipation = Participation::count();
|
||||
if (count($participationsUnique) > 0) {
|
||||
$avgParticipUser = round($totalParticipation / count($participationsUnique), 1);
|
||||
$avgParticipCustomer = round($totalParticipation / count($participationsUnique), 1);
|
||||
} else {
|
||||
$avgParticipUser = 0;
|
||||
$avgParticipCustomer = 0;
|
||||
}
|
||||
|
||||
// Tableau des dates comprises dans la table participation.
|
||||
|
|
@ -65,7 +71,7 @@ class DashboardController extends Controller
|
|||
'count',
|
||||
'countUnique',
|
||||
'totalParticipation',
|
||||
'avgParticipUser',
|
||||
'avgParticipCustomer',
|
||||
'codesEan',
|
||||
'settings'
|
||||
));
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StoreProductRequest;
|
||||
use App\Http\Requests\UpdateProductRequest;
|
||||
use App\Http\Requests\Bo\StoreProductRequest;
|
||||
use App\Http\Requests\Bo\UpdateProductRequest;
|
||||
use App\Models\Product;
|
||||
use App\Models\Range;
|
||||
use Illuminate\Support\Str;
|
||||
|
|
@ -43,7 +43,7 @@ class ProductsController extends Controller
|
|||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\StoreProductRequest $request
|
||||
* @param \App\Http\Requests\Bo\StoreProductRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(StoreProductRequest $request)
|
||||
|
|
@ -104,8 +104,8 @@ class ProductsController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\UpdateProductRequest $request
|
||||
* @param integer $id
|
||||
* @param \App\Http\Requests\Bo\UpdateProductRequest $request
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(UpdateProductRequest $request, $id)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StoreRangeRequest;
|
||||
use App\Http\Requests\UpdateRangeRequest;
|
||||
use App\Http\Requests\Bo\StoreRangeRequest;
|
||||
use App\Http\Requests\Bo\UpdateRangeRequest;
|
||||
use App\Models\Range;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,18 +6,30 @@ use App\Http\Controllers\Controller;
|
|||
use App\Mail\CourrierArcadiaError;
|
||||
use App\Models\Participation;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class WinnersListController extends Controller
|
||||
{
|
||||
/**
|
||||
* crm Api
|
||||
*
|
||||
* @var \LDCCRM\ApiV1
|
||||
*/
|
||||
private $apiCrm;
|
||||
|
||||
/**
|
||||
* WinnersListController
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Instant win list
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$winnersList = Participation::has('instantWin')->get();
|
||||
|
|
@ -25,17 +37,27 @@ class WinnersListController extends Controller
|
|||
return view('bo.winners-list.index', compact('winnersList', 'settings'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Crete and show courrier arcadia
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function courrierArcadia($id)
|
||||
{
|
||||
/** @var \App\Models\Participation $participation */
|
||||
$participation = Participation::findOrFail($id);
|
||||
|
||||
$crmUser = $this->apiCrm->getCustomer($participation->user->crm_id);
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = $participation->customer;
|
||||
|
||||
$crmUser = $this->apiCrm->getCustomer($customer->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);
|
||||
}
|
||||
|
||||
$crmId = $participation->user->crm_id;
|
||||
$crmId = $customer->crm_id;
|
||||
|
||||
$crmUser = $crmUser->user;
|
||||
|
||||
|
|
@ -48,6 +70,7 @@ class WinnersListController extends Controller
|
|||
$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";
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$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";
|
||||
|
|
@ -63,11 +86,20 @@ class WinnersListController extends Controller
|
|||
return view('bo.winners-list.arcadia', compact('participation', 'corps', 'crmId'));
|
||||
}
|
||||
|
||||
public function createCourrierArcadia(Request $request, $id)
|
||||
/**
|
||||
* Send Arcadia mail
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function createCourrierArcadia($id)
|
||||
{
|
||||
$participation = Participation::findOrFail($id);
|
||||
$instantWin = $participation->instantWin;
|
||||
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = $participation->customer;
|
||||
|
||||
if ($instantWin->prize->arcadia_operation_code !== 0 && $instantWin->prize->arcadia_support_code !== 0) {
|
||||
$fields = [
|
||||
'root' => [
|
||||
|
|
@ -105,9 +137,9 @@ class WinnersListController extends Controller
|
|||
];
|
||||
}
|
||||
|
||||
$arcadiaMail = $this->apiCrm->ArcadiaOutgoingMail($participation->user->crm_id, $fields, 'game');
|
||||
$arcadiaMail = $this->apiCrm->ArcadiaOutgoingMail($customer->crm_id, $fields, 'game');
|
||||
if ($arcadiaMail->status === 'NOK') {
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new CourrierArcadiaError($participation->user));
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new CourrierArcadiaError($customer));
|
||||
return back()->withErrors("Erreur lors de l'envoi du courrier Arcadia. Code : " .
|
||||
$arcadiaMail->code . " Message : " . $arcadiaMail->message);
|
||||
}
|
||||
|
|
|
|||
7
app/Http/Controllers/CustomerController.php
Normal file
7
app/Http/Controllers/CustomerController.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
}
|
||||
|
|
@ -1,11 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Settings;
|
||||
|
||||
class EndPageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Ended game page
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$settings = app(Settings::class)
|
||||
|
|
@ -1,21 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Requests\ParticipateRequest;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Fo\ParticipateRequest;
|
||||
use App\Mail\CourrierArcadiaError;
|
||||
use App\Mail\NotifAdmin;
|
||||
use App\Mail\NotifWinAdmin;
|
||||
use App\Mail\PrizeWon;
|
||||
use App\Mail\ReductionWon;
|
||||
use App\Models\BannedIp;
|
||||
use App\Models\Customer;
|
||||
use App\Models\InstantWin;
|
||||
use App\Models\Participation;
|
||||
use App\Models\Reduction;
|
||||
use LDCWeb\MesBR;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class EnterCodeController extends Controller
|
||||
|
|
@ -41,7 +42,17 @@ class EnterCodeController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$nbParticipations = Participation::where('user_id', Auth::user()->id)->count();
|
||||
/** @var \App\Models\Customer|null $customer */
|
||||
$customer = auth('customer')->user();
|
||||
|
||||
// * Only auth customer can access
|
||||
if (!auth('customer')->check()) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
$nbParticipations = Participation::whereHas('customer', function ($q) use ($customer) {
|
||||
$q->whereId($customer->id);
|
||||
})->count();
|
||||
$settings = app(Settings::class)->select('use_ean_codes', 'nb_participation_player')->first();
|
||||
if ($nbParticipations >= $settings->nb_participation_player) {
|
||||
return view('front.basic.participation-exhausted', compact('settings'));
|
||||
|
|
@ -61,6 +72,9 @@ class EnterCodeController extends Controller
|
|||
/** @var \App\Models\Settings $settings */
|
||||
$settings = app(Settings::class);
|
||||
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = auth('customer')->user();
|
||||
|
||||
// * Cas IP bannie.
|
||||
$ipBanned = BannedIp::where('ip', app('clientIp'))->first() === null ? 0 : 1;
|
||||
if ($ipBanned) {
|
||||
|
|
@ -68,28 +82,30 @@ class EnterCodeController extends Controller
|
|||
}
|
||||
|
||||
// * Cas nombre de participation maximale atteint.
|
||||
$nbParticipations = Participation::where('user_id', auth()->user()->id)->count();
|
||||
$nbParticipations = Participation::whereHas('customer', function ($q) use ($customer) {
|
||||
$q->whereId($customer->id);
|
||||
})->count();
|
||||
if ($nbParticipations >= $settings->nb_participation_player) {
|
||||
return view('front.basic.participation-exhausted', compact('settings'));
|
||||
}
|
||||
|
||||
// * Tous les cas "bloquants" sont passé, l'utilisateur participe à partir d'ici.
|
||||
$participation = new Participation();
|
||||
$participation->user_id = auth()->user()->id;
|
||||
$participation->code_unique_id = $request->code->id;
|
||||
$participation->code_ean_id = $request->code_ean ? $request->code_ean->id : null;
|
||||
$participation->ip = app('clientIp');
|
||||
$participation->customer()->associate($customer);
|
||||
$participation->save();
|
||||
|
||||
// * Gestion des instants gagnants.
|
||||
$userAlreadyWon = Participation::has('instantWin')
|
||||
->whereHas('user', function ($q) {
|
||||
$q->whereId(auth()->user()->id);
|
||||
->whereHas('customer', function ($q) use ($customer) {
|
||||
$q->whereId($customer->id);
|
||||
})->first();
|
||||
|
||||
// * Si l'utilisateur actuel à déjà gagné un gros lot, pas d'instant gagnant.
|
||||
if ($userAlreadyWon) {
|
||||
return $this->serveCouponWin($settings, $participation);
|
||||
return $this->serveCouponWin($settings, $participation, $customer);
|
||||
}
|
||||
|
||||
$instantWin = InstantWin::where([['appear_date', '<', now()], ['won', 0]])
|
||||
|
|
@ -98,14 +114,18 @@ class EnterCodeController extends Controller
|
|||
// Ici si fail car unique dupliqué catch.
|
||||
try {
|
||||
// Gain d'un gros lot.
|
||||
return $this->instantWin($settings, $request, $participation, $instantWin);
|
||||
return $this->instantWin($settings, $request, $participation, $customer, $instantWin);
|
||||
} catch (\ErrorException $e) {
|
||||
// Unbind instant gagnant.
|
||||
$participation->instantWin()->delete();
|
||||
// TODO: si erreur il faut envoyer un mail à equipe.web@ldc.fr
|
||||
// TODO: si erreur il faut envoyer un mail à equipe.web@ldc.fr.
|
||||
} //end try
|
||||
}
|
||||
return $this->serveCouponWin($settings, $participation);
|
||||
return $this->serveCouponWin(
|
||||
$settings,
|
||||
$participation,
|
||||
$customer
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,11 +134,17 @@ class EnterCodeController extends Controller
|
|||
* @param Settings $settings
|
||||
* @param Request $request
|
||||
* @param Participation $participation
|
||||
* @param Customer $customer
|
||||
* @param InstantWin|null $instantWin
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
private function instantWin(Settings $settings, Request $request, Participation &$participation, $instantWin)
|
||||
{
|
||||
private function instantWin(
|
||||
Settings $settings,
|
||||
Request $request,
|
||||
Participation &$participation,
|
||||
Customer $customer,
|
||||
$instantWin
|
||||
) {
|
||||
$instantWin->won = true;
|
||||
// Should save now to prevent next player win on the same winning moment.
|
||||
$instantWin->save();
|
||||
|
|
@ -128,7 +154,7 @@ class EnterCodeController extends Controller
|
|||
$instantWin->prize->arcadia_operation_code !== 0 &&
|
||||
$instantWin->prize->arcadia_support_code !== 0
|
||||
) {
|
||||
$crmId = auth()->user()->crm_id;
|
||||
$crmId = $customer->crm_id;
|
||||
|
||||
$fields = [
|
||||
'root' => [
|
||||
|
|
@ -167,11 +193,11 @@ class EnterCodeController extends Controller
|
|||
|
||||
$arcadiaMail = $this->apiCrm->ArcadiaOutgoingMail($crmId, $fields, 'game');
|
||||
if ($arcadiaMail->status === 'KO') {
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new CourrierArcadiaError(auth()->user()));
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new CourrierArcadiaError($customer));
|
||||
}
|
||||
} //end if
|
||||
|
||||
Mail::to(auth()->user()->email)->send(new PrizeWon(auth()->user(), $instantWin->prize, $settings));
|
||||
Mail::to($customer->email)->send(new PrizeWon($customer, $instantWin->prize, $settings));
|
||||
$mails = collect($settings->notification_emails);
|
||||
foreach ($mails as $mail) {
|
||||
Mail::to($mail)->send(new NotifWinAdmin($settings, $participation));
|
||||
|
|
@ -187,19 +213,23 @@ class EnterCodeController extends Controller
|
|||
*
|
||||
* @param Settings $settings
|
||||
* @param Participation $participation
|
||||
* @param Customer $customer
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
private function serveCouponWin(Settings $settings, Participation $participation)
|
||||
private function serveCouponWin(Settings $settings, Participation $participation, Customer $customer)
|
||||
{
|
||||
// Si le jeu est 100% gagnant.
|
||||
if ($settings->reductions_activated) {
|
||||
$coupon = $this->getRandomCoupon($settings);
|
||||
$crmCoupon = $this->updateCoupon($settings, $coupon->web_coupon_identifiant, $participation);
|
||||
if (!($coupon = $this->getRandomCoupon($settings))) {
|
||||
throw new \ErrorException('No web coupons are available');
|
||||
}
|
||||
// ! FIXME: repair this !!
|
||||
$crmCoupon = $this->updateCoupon($settings, $coupon->web_coupon_identifiant, $participation, $customer);
|
||||
if (!$crmCoupon) {
|
||||
$participation->delete();
|
||||
return back()->withErrors("Une erreur est survenue, merci de réessayez ultérieurement.");
|
||||
}
|
||||
Mail::to(Auth::user()->email)->send(new ReductionWon(Auth::user(), $coupon, $settings, $crmCoupon));
|
||||
Mail::to(auth('customer')->user()->email)->send(new ReductionWon($customer, $coupon, $settings, $crmCoupon));
|
||||
return view('front.basic.reduction', compact('crmCoupon', 'coupon'));
|
||||
} else {
|
||||
return view('front.basic.loose');
|
||||
|
|
@ -210,9 +240,9 @@ class EnterCodeController extends Controller
|
|||
* Get a random coupon
|
||||
*
|
||||
* @param Settings $settings
|
||||
* @return mixed
|
||||
* @return string|null
|
||||
*/
|
||||
private function getRandomCoupon(Settings $settings)
|
||||
private function getRandomCoupon(Settings $settings): ?string
|
||||
{
|
||||
$webCoupons = $settings->web_coupons;
|
||||
if (count($webCoupons) > 1) {
|
||||
|
|
@ -228,7 +258,7 @@ class EnterCodeController extends Controller
|
|||
shuffle($tmp);
|
||||
return $tmp[0];
|
||||
} else {
|
||||
return $webCoupons[0];
|
||||
return $webCoupons[0] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -238,14 +268,19 @@ class EnterCodeController extends Controller
|
|||
* @param Settings $settings
|
||||
* @param mixed $coupon
|
||||
* @param Participation $participation
|
||||
* @param Customer $customer
|
||||
* @return \App\Models\Reduction|null
|
||||
*/
|
||||
private function updateCoupon(Settings $settings, $coupon, Participation $participation)
|
||||
{
|
||||
private function updateCoupon(
|
||||
Settings $settings,
|
||||
$coupon,
|
||||
Participation $participation,
|
||||
Customer $customer
|
||||
) {
|
||||
$reduction = null;
|
||||
$mesBR = new MesBR(config('mesbr.endpoint'), $settings->reductions_site, $settings->reductions_campaign);
|
||||
|
||||
$crmUser = $this->apiCrm->getCustomer(Auth::user()->crm_id);
|
||||
$crmUser = $this->apiCrm->getCustomer($customer->crm_id);
|
||||
if ($crmUser->status === 'OK') {
|
||||
$mesBR->updateContact($crmUser->user);
|
||||
$result = $mesBR->updatePanier($crmUser->user, $coupon);
|
||||
|
|
@ -270,18 +305,27 @@ class EnterCodeController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* Show Wining proof form
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function formWinningProof()
|
||||
{
|
||||
$participation = Participation::where([
|
||||
['user_id', Auth::user()->id],
|
||||
/** @var \App\Models\Customer|null $customer */
|
||||
$customer = auth('customer')->user();
|
||||
|
||||
// * Only auth customer can access
|
||||
if (!auth('customer')->check() or \get_class($customer) === Customer::class) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
$participation = Participation::whereHas('customer', function ($q) use ($customer) {
|
||||
$q->whereId($customer->id);
|
||||
})->whereHas('instantWin')->where([
|
||||
['sticker', null],
|
||||
['ticket', null],
|
||||
['barcode', null]
|
||||
])->has('instantWin')->first();
|
||||
])->first();
|
||||
if ($participation) {
|
||||
return view('front.basic.winning-proof', compact('participation'));
|
||||
}
|
||||
|
|
@ -1,12 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\FaqQuestion;
|
||||
use App\Models\FaqTheme;
|
||||
|
||||
class FAQController extends Controller
|
||||
{
|
||||
/**
|
||||
* Faq page
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$questions = FaqQuestion::all();
|
||||
|
|
@ -1,9 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class GainsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Gains page
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if (view()->exists('front.basic.gains')) {
|
||||
18
app/Http/Controllers/Fo/HomeController.php
Normal file
18
app/Http/Controllers/Fo/HomeController.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Home page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function home()
|
||||
{
|
||||
return view('front.basic.home');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class HowToPlayController extends Controller
|
||||
{
|
||||
/**
|
||||
* How to play page
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if (view()->exists('front.basic.how-to-play')) {
|
||||
383
app/Http/Controllers/Fo/LoginController.php
Normal file
383
app/Http/Controllers/Fo/LoginController.php
Normal file
|
|
@ -0,0 +1,383 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Fo\AuthenticateRequest;
|
||||
use App\Http\Requests\Fo\UpdatePasswordRequest;
|
||||
use App\Lib\ToolboxHelper;
|
||||
use App\Mail\PasswordReset;
|
||||
use App\Mail\VerifyEmail;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Settings;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/**
|
||||
* apiCRM
|
||||
*
|
||||
* @var \LDCCRM\ApiV1
|
||||
*/
|
||||
private $apiCrm;
|
||||
|
||||
/**
|
||||
* LoginController
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show login form
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function loginForm()
|
||||
{
|
||||
if (!ToolboxHelper::isLoginAccessAllowed()) {
|
||||
abort(\response()->redirectToRoute('home'));
|
||||
}
|
||||
return view('front.basic.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate user
|
||||
*
|
||||
* @param AuthenticateRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function loginFormSubmit(AuthenticateRequest $request)
|
||||
{
|
||||
$this->authenticateUser($request);
|
||||
$this->authenticateCustomer($request);
|
||||
|
||||
return back()->withInput($request->except('password'))
|
||||
->withErrors('Les identifiants entrés sont incorrects.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Try Login User if exists (email)
|
||||
*
|
||||
* Does nothing if email does not exists in users table.
|
||||
*
|
||||
* @param AuthenticateRequest $request
|
||||
* @return void
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException If user is logged in.
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException If redirect route is not found.
|
||||
*/
|
||||
private function authenticateUser(AuthenticateRequest $request)
|
||||
{
|
||||
if (
|
||||
User::whereEmail($request->email)->exists() and
|
||||
\auth('web')->attempt([
|
||||
'email' => $request->email,
|
||||
'password' => $request->password
|
||||
], $request->remember)
|
||||
) {
|
||||
abort(redirect()->route('bo.dashboard'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try Login Customer if exists (email)
|
||||
*
|
||||
* Does nothing if email does not exists in customers table.
|
||||
*
|
||||
* @param AuthenticateRequest $request
|
||||
* @return void
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException If user is logged in.
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException If redirect route is not found.
|
||||
*/
|
||||
private function authenticateCustomer(AuthenticateRequest $request)
|
||||
{
|
||||
/** @var \App\Models\Customer|null $customerLocal */
|
||||
$customerLocal = Customer::where('email', $request->email)->first();
|
||||
|
||||
$connect = $this->apiCrm->loginCustomer($request->email, $request->password);
|
||||
|
||||
if (\optional($connect)->code === 500) {
|
||||
abort(back()->withInput($request->except("password"))
|
||||
->withErrors("La connexion est impossible pour le moment, veuillez réessayer plus tard."));
|
||||
}
|
||||
|
||||
// * Compte existant mais non activé.
|
||||
if (\optional($connect)->code === 116) {
|
||||
/** @var \App\Models\Customer $customerLocal */
|
||||
$customerLocal = Customer::create([
|
||||
'crm_id' => $connect->user->crm_id,
|
||||
'firstname' => $connect->user->firstname,
|
||||
'lastname' => $connect->user->lastname,
|
||||
'birth_date' => $connect->user->birth_date,
|
||||
'email' => $request->email,
|
||||
// TODO : MOTDEPASSE ???.
|
||||
'password' => Hash::make("MOTDEPASSE"),
|
||||
'address' => $connect->user->address,
|
||||
'address2' => $connect->user->address2,
|
||||
'town' => $connect->user->city,
|
||||
'postal_code' => $connect->user->postcode,
|
||||
'country' => $connect->user->country
|
||||
]);
|
||||
|
||||
$customerLocal->email_verify_token = Str::uuid();
|
||||
$customerLocal->saveOrFail();
|
||||
Mail::to($request->email)->send(new VerifyEmail($customerLocal));
|
||||
abort(back()->withInput($request->except("password"))
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
->withErrors("Votre compte existe mais votre email n'est pas confirmé, merci de vérifier vos emails."));
|
||||
} //end if
|
||||
|
||||
// * Connexion OK
|
||||
if (!$customerLocal and $connect->status === 'OK') {
|
||||
/** @var \App\Models\Customer $customerLocal */
|
||||
$customerLocal = Customer::create([
|
||||
'crm_id' => $connect->user->crm_id,
|
||||
'firstname' => $connect->user->firstname,
|
||||
'lastname' => $connect->user->lastname,
|
||||
'birth_date' => $connect->user->birth_date,
|
||||
'email' => $request->email,
|
||||
// TODO : MOTDEPASSE ???.
|
||||
'password' => Hash::make("MOTDEPASSE"),
|
||||
'address' => $connect->user->address,
|
||||
'address2' => $connect->user->address2,
|
||||
'town' => $connect->user->city,
|
||||
'postal_code' => $connect->user->postcode,
|
||||
'country' => $connect->user->country,
|
||||
'email_verified' => true
|
||||
]);
|
||||
} //end if
|
||||
|
||||
// * Pas de customer (non trouvé ou mot de pass invalide)
|
||||
if (!$customerLocal or \optional($connect)->code === 117) {
|
||||
abort(back()->withInput($request->except("password"))
|
||||
->withErrors("Email ou mot de passe incorrect."));
|
||||
}
|
||||
|
||||
if ($connect->status !== 'OK') {
|
||||
abort(back()->withInput($request->except("password"))
|
||||
->withErrors('Une erreur est survenue'));
|
||||
}
|
||||
|
||||
// * Enregistrer Customer is besoin
|
||||
$customerLocal->saveOrFail();
|
||||
|
||||
// * Email non vérifié
|
||||
if (!$customerLocal->email_verified) {
|
||||
$customerLocal->email_verify_token = Str::uuid();
|
||||
$customerLocal->saveOrFail();
|
||||
Mail::to($request->email)->send(new VerifyEmail($customerLocal));
|
||||
abort(back()->withInput($request->except("password"))
|
||||
->withErrors(
|
||||
'Votre compte existe mais votre email n\'est pas confirmé, merci de vérifier vos emails.'
|
||||
));
|
||||
} //end if
|
||||
|
||||
|
||||
// ??? Pas sûr.
|
||||
$tmpPwd = "MOTDEPASSE";
|
||||
if ($customerLocal and $customerLocal->isLocal()) {
|
||||
$tmpPwd = $request->password;
|
||||
}
|
||||
|
||||
// * Authentification locale
|
||||
if (auth('customer')->attempt(["email" => $request->email, "password" => $tmpPwd], $request->remember)) {
|
||||
abort(redirect()->route('saisir-code'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out
|
||||
*
|
||||
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
auth('web')->logout();
|
||||
auth('customer')->logout();
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm Email
|
||||
*
|
||||
* @param mixed $verifyToken
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function confirmEmail($verifyToken)
|
||||
{
|
||||
$result = false;
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = Customer::where('email_verify_token', $verifyToken)->first();
|
||||
if (!$customer) {
|
||||
return view('front.basic.confirm-email', compact('result'));
|
||||
}
|
||||
|
||||
$activation = $this->apiCrm->activateCustomer($customer->crm_id);
|
||||
|
||||
if ($activation->status === 'OK') {
|
||||
$customer->email_verified = true;
|
||||
$customer->email_verify_token = null;
|
||||
$customer->saveOrFail();
|
||||
$result = true;
|
||||
} else {
|
||||
// User already active.
|
||||
if ($activation->code === 110) {
|
||||
$customer->email_verified = true;
|
||||
$customer->email_verify_token = null;
|
||||
$customer->saveOrFail();
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return view('front.basic.confirm-email', compact('result'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Forgot Password form
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function forgotPassword(Request $request)
|
||||
{
|
||||
if ($request->tokenValid && $request->token) {
|
||||
$tokenValid = $request->tokenValid;
|
||||
$token = $request->token;
|
||||
return view('front.basic.forgot-password', compact('tokenValid', 'token'));
|
||||
}
|
||||
return view('front.basic.forgot-password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send password reset mail
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function mailPassword(Request $request)
|
||||
{
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_STRING);
|
||||
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = Customer::where('email', $email)->first();
|
||||
|
||||
if (!$customer) {
|
||||
$userCrm = $this->apiCrm->getCustomerByEmail($email);
|
||||
if ($userCrm->status === 'OK') {
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = Customer::create([
|
||||
'crm_id' => $userCrm->user->crm_id,
|
||||
'firstname' => $userCrm->user->firstname,
|
||||
'lastname' => $userCrm->user->lastname,
|
||||
'birth_date' => $userCrm->user->birth_date,
|
||||
'email' => $email,
|
||||
// TODO : MOTDEPASSE ???
|
||||
'password' => Hash::make("MOTDEPASSE"),
|
||||
'address' => $userCrm->user->address,
|
||||
'address2' => $userCrm->user->address2,
|
||||
'town' => $userCrm->user->city,
|
||||
'postal_code' => $userCrm->user->postcode,
|
||||
'country' => $userCrm->user->country,
|
||||
'email_verified' => true
|
||||
]);
|
||||
|
||||
if ($userCrm->user->status === 0) {
|
||||
$customer->email_verified = false;
|
||||
$customer->email_verify_token = Str::uuid();
|
||||
$customer->saveOrFail();
|
||||
Mail::to($email)->send(new VerifyEmail($customer));
|
||||
return back()->withInput($request->except("password"))
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
->withErrors("Votre compte existe mais votre email n'est pas confirmé, merci de vérifier vos emails.");
|
||||
}
|
||||
} 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 {
|
||||
return back()->withErrors("Une erreur est survenue, veuillez réessayer plus tard.");
|
||||
}
|
||||
} //end if
|
||||
} //end if
|
||||
|
||||
$customer->password_token = Str::uuid();
|
||||
$customer->saveOrFail();
|
||||
|
||||
/** @var \App\Models\Settings $settings */
|
||||
$settings = app(Settings::class);
|
||||
|
||||
Mail::to($email)->send(new PasswordReset($customer, $settings));
|
||||
|
||||
return redirect()->route('login')
|
||||
->with('success', 'Un mail de réinitialisation de votre mot de passe vous a été envoyé(e).');
|
||||
}
|
||||
|
||||
/**
|
||||
* Forgot password form show
|
||||
*
|
||||
* @param Request $request
|
||||
* @param mixed $token
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
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;
|
||||
|
||||
if (!Customer::where('password_token', $token)->exists()) {
|
||||
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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change password form submit
|
||||
*
|
||||
* @param UpdatePasswordRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function changePassword(UpdatePasswordRequest $request)
|
||||
{
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = Customer::where(
|
||||
'password_token',
|
||||
filter_var($request->token, FILTER_SANITIZE_STRING)
|
||||
)->first();
|
||||
|
||||
if (!$customer) {
|
||||
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($customer->crm_id, $newPassword);
|
||||
|
||||
if ($update->status === 'OK') {
|
||||
$customer->password_token = null;
|
||||
$customer->saveOrFail();
|
||||
return redirect()->route('login')
|
||||
->with('success', 'Vous pouvez désormais vous connecter avec votre nouveau mot de passe.');
|
||||
} else {
|
||||
if ($update->code === 123) {
|
||||
return back()
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
->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 {
|
||||
return back()->withErrors("Une erreur est survenue, veuillez réessayer plus tard.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Range;
|
||||
|
||||
class ProduitsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Produits porteurs pages
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$ranges = Range::with('products')->orderBy('id')->get();
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Fo\RegisterRequest;
|
||||
use App\Mail\VerifyEmail;
|
||||
use App\Models\Customer;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
|
@ -19,36 +20,37 @@ class RegisterController extends Controller
|
|||
// TODO : Utilité ??
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* @var \LDCCRM\ApiV1
|
||||
*/
|
||||
private $apiCrm;
|
||||
|
||||
/**
|
||||
* RegisterController
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
public function index()
|
||||
/**
|
||||
* Register form
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return view('front.basic.register-crm');
|
||||
}
|
||||
|
||||
public function register(Request $request)
|
||||
/**
|
||||
* Register form submit
|
||||
*
|
||||
* @param RegisterRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function registerSubmit(RegisterRequest $request)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'lastname' => 'required|string|max:255',
|
||||
'firstname' => 'required|string|max:255',
|
||||
'birth_date' => 'required|string|max:10',
|
||||
'email' => 'required|string|email|max:255|unique:users|confirmed',
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
'address' => 'required|string|max:255',
|
||||
'address2' => 'max:255',
|
||||
'town' => 'required|string|max:255',
|
||||
'postal_code' => 'required|string|max:255',
|
||||
'country' => 'required|string|max:255',
|
||||
'reglement' => 'accepted',
|
||||
]);
|
||||
|
||||
$lastname = filter_var($request->lastname, FILTER_SANITIZE_STRING);
|
||||
$firstname = filter_var($request->firstname, FILTER_SANITIZE_STRING);
|
||||
$birthdate = $request->birth_date;
|
||||
|
|
@ -64,7 +66,7 @@ class RegisterController extends Controller
|
|||
|
||||
$MJ = Carbon::now()->subYears(18);
|
||||
|
||||
if ($this->isSQLDate($birthdate)) {
|
||||
if ($this->isSqlDate($birthdate)) {
|
||||
$d = Carbon::createFromFormat('Y-m-d', $birthdate);
|
||||
if (!$d->lessThanOrEqualTo($MJ)) {
|
||||
return back()
|
||||
|
|
@ -75,8 +77,8 @@ class RegisterController extends Controller
|
|||
$d = Carbon::createFromFormat('d/m/Y', $birthdate);
|
||||
if (!$d->lessThanOrEqualTo($MJ)) {
|
||||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Vous devez être majeur pour vous inscrire au jeu.");
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Vous devez être majeur pour vous inscrire au jeu.");
|
||||
}
|
||||
|
||||
$birthdate = $d->toDateString();
|
||||
|
|
@ -84,19 +86,32 @@ class RegisterController extends Controller
|
|||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Erreur sur le champs : date de naissance.");
|
||||
}//end if
|
||||
} //end if
|
||||
|
||||
$crmUser = $this->apiCrm->createCustomer($email, $password, $firstname, $lastname, $optin, $birthdate, null, $address, $address2, $town, $postcode, ucfirst($country));
|
||||
$crmUser = $this->apiCrm->createCustomer(
|
||||
$email,
|
||||
$password,
|
||||
$firstname,
|
||||
$lastname,
|
||||
$optin,
|
||||
$birthdate,
|
||||
null,
|
||||
$address,
|
||||
$address2,
|
||||
$town,
|
||||
$postcode,
|
||||
ucfirst($country)
|
||||
);
|
||||
|
||||
if ($crmUser->status === 'OK') {
|
||||
$user = User::create([
|
||||
$customer = Customer::create([
|
||||
'crm_id' => $crmUser->user->crm_id,
|
||||
'firstname' => $firstname,
|
||||
'lastname' => $lastname,
|
||||
'birth_date' => $birthdate,
|
||||
'email' => $email,
|
||||
'password' => Hash::make("MOTDEPASSE"),
|
||||
// TODO : ???
|
||||
// TODO : ???
|
||||
'address' => $address,
|
||||
'address2' => $address2,
|
||||
'town' => $town,
|
||||
|
|
@ -105,7 +120,7 @@ class RegisterController extends Controller
|
|||
'email_verify_token' => $tokenMail,
|
||||
]);
|
||||
|
||||
Mail::to($email)->send(new VerifyEmail($user));
|
||||
Mail::to($email)->send(new VerifyEmail($customer));
|
||||
|
||||
return redirect()->route('login')
|
||||
->with('success', "Pour finaliser votre inscription, merci de cliquer sur le lien qui vient de vous être envoyé par email<br>" .
|
||||
|
|
@ -113,20 +128,26 @@ 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) {
|
||||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Un compte utilisateur est déjà associé à votre email.");
|
||||
} else {
|
||||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Une erreur est survenue, merci de recommencer.");
|
||||
}
|
||||
}//end if
|
||||
} //end if
|
||||
|
||||
if ($crmUser->code === 103) {
|
||||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Un compte utilisateur est déjà associé à votre email.");
|
||||
}
|
||||
|
||||
return back()
|
||||
->withInput($request->except('password'))
|
||||
->withErrors("Une erreur est survenue, merci de recommencer.");
|
||||
}
|
||||
|
||||
private function isSQLDate($date)
|
||||
/**
|
||||
* Regex is SQL date
|
||||
*
|
||||
* @param mixed $date
|
||||
* @return boolean
|
||||
*/
|
||||
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;
|
||||
|
|
@ -134,6 +155,12 @@ class RegisterController extends Controller
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regex is form date
|
||||
*
|
||||
* @param mixed $date
|
||||
* @return boolean
|
||||
*/
|
||||
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)) {
|
||||
|
|
@ -1,11 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Settings;
|
||||
|
||||
class TeaserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Teaser page
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$settings = app(Settings::class)
|
||||
43
app/Http/Controllers/Fo/ViewContentController.php
Normal file
43
app/Http/Controllers/Fo/ViewContentController.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Enums\ContentPageType;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Content;
|
||||
|
||||
class ViewContentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Reglement page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function reglement()
|
||||
{
|
||||
$content = Content::findOrFail(ContentPageType::reglement()->value);
|
||||
return view('front.basic.reglement', compact('content'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Charte page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function charte()
|
||||
{
|
||||
$content = Content::findOrFail(ContentPageType::charte()->value);
|
||||
return view('front.basic.charte', compact('content'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Legals page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function legals()
|
||||
{
|
||||
$content = Content::findOrFail(ContentPageType::legals()->value);
|
||||
return view('front.basic.legals', compact('content'));
|
||||
}
|
||||
}
|
||||
123
app/Http/Controllers/Fo/WinningProofController.php
Normal file
123
app/Http/Controllers/Fo/WinningProofController.php
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Fo\SubmitWinningProof;
|
||||
use App\Mail\NotifAdmin;
|
||||
use App\Mail\WinningProofMail;
|
||||
use App\Models\Participation;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class WinningProofController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \LDCCRM\ApiV1
|
||||
*/
|
||||
private $apiCrm;
|
||||
|
||||
/**
|
||||
* WinningProofController
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit Winning proof
|
||||
*
|
||||
* @param SubmitWinningProof $request
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function sendWinningProof(SubmitWinningProof $request)
|
||||
{
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = auth('customer')->user();
|
||||
|
||||
// On récupère la participation gagnante en attente des infos.
|
||||
/** @var \App\Models\Participation|null $participation */
|
||||
$participation = Participation::whereHas('customer', function ($q) use ($customer) {
|
||||
$q->whereId($customer->id);
|
||||
})->whereHas('instantWin')->where([
|
||||
['sticker', null],
|
||||
['ticket', null],
|
||||
['barcode', null]
|
||||
])->first();
|
||||
|
||||
if (!$participation) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
/** @var \Illuminate\Http\UploadedFile $sticker */
|
||||
$sticker = $request->sticker;
|
||||
/** @var \Illuminate\Http\UploadedFile $ticket */
|
||||
$ticket = $request->ticket;
|
||||
/** @var \Illuminate\Http\UploadedFile $barcode */
|
||||
$barcode = $request->barcode;
|
||||
|
||||
// * Mise à jour de l'utilisateur en local.
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer->fill($request->validated());
|
||||
$customer->saveOrFail();
|
||||
|
||||
// Mise à jour utilisateur dans la CRM.
|
||||
$update = $this->apiCrm->updateCustomer(
|
||||
$customer->crm_id,
|
||||
$customer->firstname,
|
||||
$customer->lastname,
|
||||
null,
|
||||
null,
|
||||
$customer->phone,
|
||||
$customer->address,
|
||||
$customer->address2,
|
||||
$customer->town,
|
||||
$customer->postal_code,
|
||||
ucfirst($request->country)
|
||||
);
|
||||
if ($update->status !== 'OK') {
|
||||
Log::warning('Erreur lors de la mise a jour du user (crm_id : ' . $customer->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 : ' .
|
||||
$customer->crm_id . ') - code : ' . $update->code . ' - message : ' . $update->message
|
||||
));
|
||||
}
|
||||
|
||||
$participationId = $participation->id;
|
||||
$stickerFileName = $participationId . '-sticker.' . $sticker->extension();
|
||||
$sticker->move(public_path('fichiers/preuve-de-gain/' . $participationId . '/'), $stickerFileName);
|
||||
$stickerPath = public_path() . '/fichiers/preuve-de-gain/' . $participationId . '/' . $stickerFileName;
|
||||
|
||||
$ticketFileName = $participationId . '-ticket.' . $ticket->extension();
|
||||
$ticket->move(public_path('fichiers/preuve-de-gain/' . $participationId . '/'), $ticketFileName);
|
||||
$ticketPath = public_path() . '/fichiers/preuve-de-gain/' . $participationId . '/' . $ticketFileName;
|
||||
|
||||
$barcodeFileName = $participationId . '-code-barre.' . $barcode->extension();
|
||||
$barcode->move(public_path('fichiers/preuve-de-gain/' . $participationId . '/'), $barcodeFileName);
|
||||
$barcodePath = public_path() . '/fichiers/preuve-de-gain/' . $participationId . '/' . $barcodeFileName;
|
||||
|
||||
$participation->sticker = $stickerFileName;
|
||||
$participation->ticket = $ticketFileName;
|
||||
$participation->barcode = $barcodeFileName;
|
||||
$participation->saveOrFail();
|
||||
|
||||
/** @var \App\Models\Settings $settings */
|
||||
$settings = app(Settings::class);
|
||||
$mails = \collect($settings->notification_emails);
|
||||
foreach ($mails as $mail) {
|
||||
Mail::to($mail)->send(new WinningProofMail(
|
||||
$stickerPath,
|
||||
$ticketPath,
|
||||
$barcodePath,
|
||||
$participation,
|
||||
$customer,
|
||||
$settings
|
||||
));
|
||||
}
|
||||
|
||||
return view('front.basic.replay');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function home()
|
||||
{
|
||||
return view('front.basic.home');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,286 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\PasswordReset;
|
||||
use App\Mail\VerifyEmail;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
private $apiCrm;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('front.basic.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate user
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function authenticate(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_EMAIL);
|
||||
$password = $request->password;
|
||||
$remember = $request->remember !== null ? true : false;
|
||||
|
||||
/** @var \App\Models\User|null $userLocal */
|
||||
$userLocal = User::where('email', $email)->first();
|
||||
|
||||
if ($userLocal) {
|
||||
if ($userLocal->email_verified === 1) {
|
||||
if (!$userLocal->isLocal()) {
|
||||
$connect = $this->apiCrm->loginCustomer($email, $password);
|
||||
|
||||
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 {
|
||||
return back()->withInput($request->except("password"))
|
||||
->withErrors("Email ou mot de passe incorrect.");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$userLocal->email_verify_token = Str::uuid();
|
||||
$userLocal->saveOrFail();
|
||||
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.'
|
||||
);
|
||||
}//end if
|
||||
} else {
|
||||
$connect = $this->apiCrm->loginCustomer($email, $password);
|
||||
|
||||
if ($connect->status === 'OK ') {
|
||||
/** @var \App\Models\User $userLocal */
|
||||
$userLocal = User::create([
|
||||
'crm_id' => $connect->user->crm_id,
|
||||
'firstname' => $connect->user->firstname,
|
||||
'lastname' => $connect->user->lastname,
|
||||
'birth_date' => $connect->user->birth_date,
|
||||
'email' => $email,
|
||||
// TODO : MOTDEPASSE ???.
|
||||
'password' => Hash::make("MOTDEPASSE"),
|
||||
'address' => $connect->user->address,
|
||||
'address2' => $connect->user->address2,
|
||||
'town' => $connect->user->city,
|
||||
'postal_code' => $connect->user->postcode,
|
||||
'country' => $connect->user->country,
|
||||
'email_verified ' => 1
|
||||
]);
|
||||
} else {
|
||||
// Compte existant mais non activé.
|
||||
if ($connect->code === 116) {
|
||||
/** @var \App\Models\User $userLocal */
|
||||
$userLocal = User::create([
|
||||
'crm_id' => $connect->user->crm_id,
|
||||
'firstname' => $connect->user->firstname,
|
||||
'lastname' => $connect->user->lastname,
|
||||
'birth_date' => $connect->user->birth_date,
|
||||
'email' => $email,
|
||||
// TODO : MOTDEPASSE ???.
|
||||
'password' => Hash::make("MOTDEPASSE"),
|
||||
'address' => $connect->user->address,
|
||||
'address2' => $connect->user->address2,
|
||||
'town' => $connect->user->city,
|
||||
'postal_code' => $connect->user->postcode,
|
||||
'country ' => $connect->user->country
|
||||
]);
|
||||
|
||||
$userLocal->email_verify_token = Str::uuid();
|
||||
$userLocal->saveOrFail();
|
||||
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("La connexion est impossible pour le moment, veuillez réessayer plus tard.");
|
||||
} else {
|
||||
return back()->withInput($request->except("password"))
|
||||
->withErrors("Email ou mot de passe incorrect.");
|
||||
} //end if
|
||||
} //end if
|
||||
}//end if
|
||||
|
||||
// TODO : Modifier avec separation guard.
|
||||
$tmpPwd = "MOTDEPASSE";
|
||||
if ($userLocal and $userLocal->isLocal()) {
|
||||
$tmpPwd = $password;
|
||||
}
|
||||
|
||||
if (Auth::attempt(["email" => $email, "password" => $tmpPwd], $remember)) {
|
||||
if ($userLocal and $userLocal->isLocal()) {
|
||||
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()
|
||||
{
|
||||
Auth::logout();
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
public function confirmEmail($verifyToken)
|
||||
{
|
||||
$result = false;
|
||||
$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;
|
||||
$user->save();
|
||||
$result = true;
|
||||
} else {
|
||||
// User already active.
|
||||
if ($activation->code === 110) {
|
||||
$user->email_verified = 1;
|
||||
$user->email_verify_token = null;
|
||||
$user->save();
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return view('front.basic.confirm-email', compact('result'));
|
||||
}
|
||||
|
||||
public function forgotPassword(Request $request)
|
||||
{
|
||||
if ($request->tokenValid && $request->token) {
|
||||
$tokenValid = $request->tokenValid;
|
||||
$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)) {
|
||||
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) {
|
||||
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)
|
||||
{
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_STRING);
|
||||
$user = User::where('email', $email)->first();
|
||||
|
||||
if (!$user) {
|
||||
$userCrm = $this->apiCrm->getCustomerByEmail($email);
|
||||
if ($userCrm->status === 'OK') {
|
||||
$user = User::create([
|
||||
'crm_id' => $userCrm->user->crm_id,
|
||||
'firstname' => $userCrm->user->firstname,
|
||||
'lastname' => $userCrm->user->lastname,
|
||||
'birth_date' => $userCrm->user->birth_date,
|
||||
'email' => $email,
|
||||
// TODO : MOTDEPASSE ???
|
||||
'password' => Hash::make("MOTDEPASSE"),
|
||||
'address' => $userCrm->user->address,
|
||||
'address2' => $userCrm->user->address2,
|
||||
'town' => $userCrm->user->city,
|
||||
'postal_code' => $userCrm->user->postcode,
|
||||
'country' => $userCrm->user->country,
|
||||
'email_verified' => 1
|
||||
]);
|
||||
|
||||
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.");
|
||||
}
|
||||
} 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 {
|
||||
return back()->withErrors("Une erreur est survenue, veuillez réessayer plus tard.");
|
||||
}
|
||||
} //end if
|
||||
}//end if
|
||||
|
||||
$user->password_token = Str::uuid();
|
||||
$user->save();
|
||||
/** @var \App\Models\Settings $settings */
|
||||
$settings = app(Settings::class);
|
||||
Mail::to($email)->send(new PasswordReset($user, $settings));
|
||||
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)
|
||||
{
|
||||
$request->validate([
|
||||
'password' => 'required|min:8|confirmed',
|
||||
]);
|
||||
|
||||
$user = User::where('password_token', filter_var($request->token, FILTER_SANITIZE_STRING))->first();
|
||||
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;
|
||||
$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) {
|
||||
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 {
|
||||
return back()->withErrors("Une erreur est survenue, veuillez réessayer plus tard.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Content;
|
||||
|
||||
class ViewContentController extends Controller
|
||||
{
|
||||
public function reglement()
|
||||
{
|
||||
$content = Content::find(3);
|
||||
return view('front.basic.reglement', compact('content'));
|
||||
}
|
||||
|
||||
public function charte()
|
||||
{
|
||||
$content = Content::find(2);
|
||||
return view('front.basic.charte', compact('content'));
|
||||
}
|
||||
|
||||
public function legals()
|
||||
{
|
||||
$content = Content::find(1);
|
||||
return view('front.basic.legals', compact('content'));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\NotifAdmin;
|
||||
use App\Mail\WinningProof;
|
||||
use App\Models\Participation;
|
||||
use App\Models\Settings;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class WinningProofController extends Controller
|
||||
{
|
||||
private $apiCrm;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
}
|
||||
|
||||
public function sendWinningProof(Request $request)
|
||||
{
|
||||
// On récupère la participation gagnante en attente des infos
|
||||
$participation = Participation::where([
|
||||
['user_id', Auth::user()->id],
|
||||
['sticker', null],
|
||||
['ticket', null],
|
||||
['barcode', null]
|
||||
])->has('instantWin')->first();
|
||||
if (!$participation) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'lastname' => 'required|string|max:255',
|
||||
'firstname' => 'required|string|max:255',
|
||||
'address' => 'required|string|max:255',
|
||||
'address2' => 'max:255',
|
||||
'town' => 'required|string|max:255',
|
||||
'postal_code' => 'required|max:255',
|
||||
'country' => 'required|string|max:255',
|
||||
'phone' => 'required|string|max:50',
|
||||
'sticker' => 'required|mimes:jpeg,png,jpg,pdf|max:2048',
|
||||
'ticket' => 'required|mimes:jpeg,png,jpg,pdf|max:2048',
|
||||
'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);
|
||||
$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;
|
||||
|
||||
// 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->postal_code = $postalCode;
|
||||
$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
|
||||
));
|
||||
}
|
||||
|
||||
$participationId = $participation->id;
|
||||
$stickerFileName = $participationId . '-sticker.' . $sticker->extension();
|
||||
$sticker->move(public_path('fichiers/preuve-de-gain/' . $participationId . '/'), $stickerFileName);
|
||||
$stickerPath = public_path() . '/fichiers/preuve-de-gain/' . $participationId . '/' . $stickerFileName;
|
||||
|
||||
$ticketFileName = $participationId . '-ticket.' . $ticket->extension();
|
||||
$ticket->move(public_path('fichiers/preuve-de-gain/' . $participationId . '/'), $ticketFileName);
|
||||
$ticketPath = public_path() . '/fichiers/preuve-de-gain/' . $participationId . '/' . $ticketFileName;
|
||||
|
||||
$barcodeFileName = $participationId . '-code-barre.' . $barcode->extension();
|
||||
$barcode->move(public_path('fichiers/preuve-de-gain/' . $participationId . '/'), $barcodeFileName);
|
||||
$barcodePath = public_path() . '/fichiers/preuve-de-gain/' . $participationId . '/' . $barcodeFileName;
|
||||
|
||||
$participation->sticker = $stickerFileName;
|
||||
$participation->ticket = $ticketFileName;
|
||||
$participation->barcode = $barcodeFileName;
|
||||
$participation->save();
|
||||
|
||||
/** @var \App\Models\Settings $settings */
|
||||
$settings = app(Settings::class);
|
||||
$mails = \collect($settings->notification_emails);
|
||||
foreach ($mails as $mail) {
|
||||
Mail::to($mail)->send(new WinningProof(
|
||||
$stickerPath,
|
||||
$ticketPath,
|
||||
$barcodePath,
|
||||
$participation,
|
||||
$user,
|
||||
$settings
|
||||
));
|
||||
}
|
||||
|
||||
return view('front.basic.replay');
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class IsAdmin
|
||||
{
|
||||
|
|
@ -16,11 +15,11 @@ class IsAdmin
|
|||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
/** @var \App\Models\User|null $user */
|
||||
$user = Auth::user();
|
||||
/** @var \App\Models\User|\App\Models\Customer|null $user */
|
||||
$user = auth('web')->user() ?? auth('customer')->user();
|
||||
if ($user and $user->isLocal()) {
|
||||
return $next($request);
|
||||
}
|
||||
abort(404, "Cette page n'existe pas.");
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class IsSuperAdmin
|
||||
{
|
||||
|
|
@ -16,8 +15,8 @@ class IsSuperAdmin
|
|||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
/** @var \App\Models\User|null $user */
|
||||
$user = Auth::user();
|
||||
/** @var \App\Models\User|\App\Models\Customer|null $user */
|
||||
$user = auth('web')->user() ?? auth('customer')->user();
|
||||
if ($user and $user->isAdmin()) {
|
||||
return $next($request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
|
|
@ -16,10 +16,10 @@ class RedirectIfAuthenticated
|
|||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
public function handle(Request $request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
return \redirect()->route('login');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
|
|
@ -15,8 +15,8 @@ class CodeSearchRequest extends FormRequest
|
|||
{
|
||||
// ? Is auth and super admin ?
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
return auth()->check() and $user->isAdmin();
|
||||
$user = auth('web')->user();
|
||||
return auth('web')->check() and $user->isAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use App\Models\Code;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
|
@ -27,8 +27,8 @@ class ExportCodesRequest extends FormRequest
|
|||
]);
|
||||
// ? Is auth and super admin, also is json ?
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
return auth()->check() and $user->isAdmin() and $this->json();
|
||||
$user = auth('web')->user();
|
||||
return auth('web')->check() and $user->isAdmin() and $this->json();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
|
|
@ -15,8 +15,8 @@ class GenerateCodesRequest extends FormRequest
|
|||
{
|
||||
// ? Is auth and super admin
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
return auth()->check() and $user->isAdmin();
|
||||
$user = auth('web')->user();
|
||||
return auth('web')->check() and $user->isAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
|
@ -14,7 +14,7 @@ class StoreProductRequest extends FormRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check();
|
||||
return auth('web')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
|
@ -14,7 +14,7 @@ class StoreRangeRequest extends FormRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check();
|
||||
return auth('web')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
30
app/Http/Requests/Bo/UpdateContentRequest.php
Normal file
30
app/Http/Requests/Bo/UpdateContentRequest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateContentRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth('web')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'value' => 'required|min:5'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
|
@ -14,7 +14,7 @@ class UpdateProductRequest extends FormRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check();
|
||||
return auth('web')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -31,8 +31,8 @@ class UpdateProductRequest extends FormRequest
|
|||
'mimes:jpeg,png,jpg',
|
||||
'max:2048',
|
||||
Rule::dimensions()
|
||||
->maxWidth(config('theme.product_image_maxwidth'))
|
||||
->maxHeight(config('theme.product_image_maxheight'))
|
||||
->maxWidth(config('theme.product_image_maxwidth'))
|
||||
->maxHeight(config('theme.product_image_maxheight'))
|
||||
],
|
||||
'range_id' => 'exists:ranges,id'
|
||||
];
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
|
@ -14,7 +14,7 @@ class UpdateRangeRequest extends FormRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check();
|
||||
return auth('web')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -24,8 +24,8 @@ class UpdateSettingsRequest extends FormRequest
|
|||
'web_coupons' => collect(\json_decode($this->web_coupons, true))->toArray(),
|
||||
]);
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
return auth()->check() and $user->isAdmin();
|
||||
$user = auth('web')->user();
|
||||
return auth('web')->check() and $user->isAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
37
app/Http/Requests/Fo/AuthenticateRequest.php
Normal file
37
app/Http/Requests/Fo/AuthenticateRequest.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Fo;
|
||||
|
||||
use App\Lib\ToolboxHelper;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AuthenticateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
$this->merge([
|
||||
'remember' => $this->remember ? true : false
|
||||
]);
|
||||
|
||||
return ToolboxHelper::isLoginAccessAllowed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'email' => 'required|email:rfc,dns,spoof,filter',
|
||||
'password' => 'required',
|
||||
'remember' => 'required|boolean'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Fo;
|
||||
|
||||
use App\Models\Code;
|
||||
use App\Models\CodeEan;
|
||||
|
|
@ -51,7 +51,7 @@ class ParticipateRequest extends FormRequest
|
|||
]);
|
||||
}
|
||||
|
||||
return auth()->check();
|
||||
return auth('customer')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -61,7 +61,9 @@ class ParticipateRequest extends FormRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = auth('customer')->user();
|
||||
$rules = [
|
||||
'accept_rules' => [
|
||||
'required', 'boolean',
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
|
|
@ -74,7 +76,7 @@ class ParticipateRequest extends FormRequest
|
|||
'code' => [
|
||||
'required',
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
function ($attribute, $value, $fail) {
|
||||
function ($attribute, $value, $fail) use ($customer) {
|
||||
if (
|
||||
$value === false or
|
||||
!\is_object($value) or
|
||||
|
|
@ -88,10 +90,11 @@ class ParticipateRequest extends FormRequest
|
|||
}
|
||||
|
||||
// * Check si l'utilisateur n'a pas déjà utilisé ce code.
|
||||
$query = Participation::where([
|
||||
['code_unique_id', $this->code->id],
|
||||
['user_id', auth()->user()->id]
|
||||
]);
|
||||
$query = Participation::whereHas('customer', function ($q) use ($customer) {
|
||||
$q->whereId($customer->id);
|
||||
})->whereHas('code', function ($q) {
|
||||
$q->whereId($this->code->id);
|
||||
});
|
||||
if ($query->exists()) {
|
||||
$fail('Vous avez déjà utilisé ce code.');
|
||||
}
|
||||
|
|
@ -99,8 +102,9 @@ class ParticipateRequest extends FormRequest
|
|||
/** @var \App\Models\Settings $settings */
|
||||
$settings = app(Settings::class);
|
||||
|
||||
$codeNbUsage = Participation::where('code_unique_id', $this->code->id)
|
||||
->count();
|
||||
$codeNbUsage = Participation::whereHas('code', function ($q) {
|
||||
$q->whereId($this->code->id);
|
||||
})->count();
|
||||
|
||||
// * Gestion du nombre d'utilisation d'un code.
|
||||
if ($codeNbUsage >= $settings->nb_unique_code_use) {
|
||||
|
|
@ -111,7 +115,7 @@ class ParticipateRequest extends FormRequest
|
|||
$this->code->code_used = 1;
|
||||
}
|
||||
}
|
||||
$this->code->save();
|
||||
$this->code->saveOrFail();
|
||||
}
|
||||
]
|
||||
];
|
||||
40
app/Http/Requests/Fo/RegisterRequest.php
Normal file
40
app/Http/Requests/Fo/RegisterRequest.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Fo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RegisterRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth('customer')->guest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'lastname' => 'required|string|max:255',
|
||||
'firstname' => 'required|string|max:255',
|
||||
'birth_date' => 'required|string|max:10',
|
||||
'email' => 'required|string|email:spoof,rfc,filter,dns|max:255|unique:users|confirmed',
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
'address' => 'required|string|max:255',
|
||||
'address2' => 'max:255',
|
||||
'town' => 'required|string|max:255',
|
||||
'postal_code' => 'required|string|max:255',
|
||||
'country' => 'required|string|max:255',
|
||||
'reglement' => 'accepted',
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Requests/Fo/SubmitWinningProof.php
Normal file
40
app/Http/Requests/Fo/SubmitWinningProof.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Fo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SubmitWinningProof extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth('customer')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'lastname' => 'required|string|max:255',
|
||||
'firstname' => 'required|string|max:255',
|
||||
'address' => 'required|string|max:255',
|
||||
'address2' => 'nullable|string|max:255',
|
||||
'town' => 'required|string|max:255',
|
||||
'postal_code' => 'required|max:255',
|
||||
'country' => 'required|string|max:255',
|
||||
'phone' => 'required|string|max:50',
|
||||
'sticker' => 'required|mimes:jpeg,png,jpg,pdf|max:2048',
|
||||
'ticket' => 'required|mimes:jpeg,png,jpg,pdf|max:2048',
|
||||
'barcode' => 'required|mimes:jpeg,png,jpg,pdf|max:2048',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Fo/UpdatePasswordRequest.php
Normal file
30
app/Http/Requests/Fo/UpdatePasswordRequest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Fo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdatePasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'password' => 'required|min:8|confirmed'
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Http/Requests/SaveBannedIpListRequest.php
Normal file
34
app/Http/Requests/SaveBannedIpListRequest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SaveBannedIpListRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
$this->merge([
|
||||
'ips' => \is_array($this->ips) ? $this->ips : []
|
||||
]);
|
||||
return auth('web')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'ips' => 'required|array',
|
||||
'ips.*' => 'required|ip'
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Lib/ToolboxHelper.php
Normal file
34
app/Lib/ToolboxHelper.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Lib;
|
||||
|
||||
use Illuminate\Routing\Route as RoutingRoute;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
abstract class ToolboxHelper
|
||||
{
|
||||
/**
|
||||
* * Needed rules as backend and frontend shares the same login functions
|
||||
* Determine if login is allowed only if:
|
||||
* Intended url was a BO route (and not already logged in as web guard),
|
||||
* else customer is not already logged in.
|
||||
*
|
||||
* ! The only way to log in as admin is to access a bo route first.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isLoginAccessAllowed(): bool
|
||||
{
|
||||
$isBo = false;
|
||||
|
||||
$path = \parse_url(\session()->get('url.intended', url('/')), \PHP_URL_PATH);
|
||||
|
||||
collect(Route::getRoutes()->getRoutes())
|
||||
->map(function (RoutingRoute $route) use (&$isBo, $path) {
|
||||
if (trim($path, '/') === $route->uri() and trim($route->getPrefix(), '/') === 'bo') {
|
||||
$isBo = true;
|
||||
}
|
||||
});
|
||||
return $isBo ? auth('web')->guest() : auth('customer')->guest();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
|
|
@ -14,21 +14,21 @@ class CourrierArcadiaError extends Mailable implements ShouldQueue
|
|||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* User
|
||||
* Customer
|
||||
*
|
||||
* @var \App\Models\User
|
||||
* @var \App\Models\Customer
|
||||
*/
|
||||
private $user;
|
||||
private $customer;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Customer $customer
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
public function __construct(Customer $customer)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->customer = $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -38,8 +38,8 @@ class CourrierArcadiaError extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function build()
|
||||
{
|
||||
$user = $this->user;
|
||||
$customer = $this->customer;
|
||||
return $this->subject("Erreur envoi courrier arcadia")
|
||||
->view('front.basic.error-arcadia-email', compact('user'));
|
||||
->view('front.basic.error-arcadia-email', compact('customer'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
|
|
@ -12,16 +14,29 @@ class PasswordReset extends Mailable implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected $user, $settings;
|
||||
/**
|
||||
* Customer
|
||||
*
|
||||
* @var Customer
|
||||
*/
|
||||
protected $customer;
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
* @var Settings
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
* @param Customer $customer
|
||||
* @param Settings $settings
|
||||
*/
|
||||
public function __construct($user, $settings)
|
||||
public function __construct(Customer $customer, Settings $settings)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->customer = $customer;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
|
|
@ -32,6 +47,8 @@ class PasswordReset extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->subject('Changement de votre mot de passe')->view('front.basic.password-email')->with(['user' => $this->user, 'settings' => $this->settings]);
|
||||
return $this->subject('Changement de votre mot de passe')
|
||||
->view('front.basic.password-email')
|
||||
->with(['customer' => $this->customer, 'settings' => $this->settings]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\Prize;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
|
|
@ -12,16 +15,28 @@ class PrizeWon extends Mailable implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $user, $prize, $settings;
|
||||
/** @var \App\Models\User $user */
|
||||
private $user;
|
||||
|
||||
/** @var \App\Models\Prize $prize */
|
||||
private $prize;
|
||||
|
||||
/** @var \App\Models\Settings $settings */
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
* @param Customer $customer
|
||||
* @param Prize $prize
|
||||
* @param Settings $settings
|
||||
*/
|
||||
public function __construct($user, $prize, $settings)
|
||||
{
|
||||
$this->user = $user;
|
||||
public function __construct(
|
||||
Customer $customer,
|
||||
Prize $prize,
|
||||
Settings $settings
|
||||
) {
|
||||
$this->customer = $customer;
|
||||
$this->prize = $prize;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
|
@ -33,7 +48,9 @@ class PrizeWon extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->subject("Félicitations " . $this->user->firstname . ", vous avez remporté 1 " . $this->prize->label_one . " !")->view('front.basic.prize-mail')
|
||||
->with(['user' => $this->user, 'prize' => $this->prize, 'settings' => $this->settings]);
|
||||
return $this->subject("Félicitations " . $this->customer->firstname .
|
||||
", vous avez remporté 1 " . $this->prize->label_one . " !")
|
||||
->view('front.basic.prize-mail')
|
||||
->with(['customer' => $this->customer, 'prize' => $this->prize, 'settings' => $this->settings]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
|
|
@ -12,16 +13,25 @@ class ReductionWon extends Mailable implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $user, $coupon, $settings, $crmCoupon;
|
||||
/**
|
||||
* Customer
|
||||
*
|
||||
* @var Customer
|
||||
*/
|
||||
private $customer;
|
||||
|
||||
private $coupon,
|
||||
private $settings,
|
||||
private $crmCoupon;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user, $coupon, $settings, $crmCoupon)
|
||||
public function __construct(Customer $customer, $coupon, $settings, $crmCoupon)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->customer = $customer;
|
||||
$this->coupon = $coupon;
|
||||
$this->settings = $settings;
|
||||
$this->crmCoupon = $crmCoupon;
|
||||
|
|
@ -34,7 +44,13 @@ class ReductionWon extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->subject($this->user->firstname . ", n'attendez plus pour imprimer votre bon d'achat " . $this->settings->name . " !")->view('front.basic.reduction-mail')
|
||||
->with(['user' => $this->user, 'coupon' => $this->coupon, 'settings' => $this->settings, 'crmCoupon' => $this->crmCoupon]);
|
||||
return $this->subject($this->customer->firstname . ", n'attendez plus pour imprimer votre bon d'achat " .
|
||||
$this->settings->name . " !")->view('front.basic.reduction-mail')
|
||||
->with([
|
||||
'customer' => $this->customer,
|
||||
'coupon' => $this->coupon,
|
||||
'settings' => $this->settings,
|
||||
'crmCoupon' => $this->crmCoupon
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
|
|
@ -12,16 +13,17 @@ class VerifyEmail extends Mailable implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected $user;
|
||||
/** @var \App\Models\Customer $customer */
|
||||
protected $customer;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
* @param Customer $customer
|
||||
*/
|
||||
public function __construct($user)
|
||||
public function __construct(Customer $customer)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->customer = $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -31,6 +33,8 @@ class VerifyEmail extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->subject("Activation du compte")->view('front.basic.verifyemail')->with('user', $this->user);
|
||||
return $this->subject("Activation du compte")
|
||||
->view('front.basic.verifyemail')
|
||||
->with('customer', $this->customer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class WinningProof extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $sticker, $ticket, $barcode, $participation, $user, $settings;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($sticker, $ticket, $barcode, $participation, $user, $settings)
|
||||
{
|
||||
$this->sticker = $sticker;
|
||||
$this->ticket = $ticket;
|
||||
$this->barcode = $barcode;
|
||||
$this->participation = $participation;
|
||||
$this->user = $user;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$participation = $this->participation;
|
||||
$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);
|
||||
}
|
||||
}
|
||||
92
app/Mail/WinningProofMail.php
Normal file
92
app/Mail/WinningProofMail.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\Participation;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class WinningProofMail extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var string */
|
||||
private $stickerPath;
|
||||
|
||||
/** @var string */
|
||||
private $ticketPath;
|
||||
|
||||
/** @var string */
|
||||
private $barcodePath;
|
||||
|
||||
/**
|
||||
* Participation
|
||||
*
|
||||
* @var Participation
|
||||
*/
|
||||
private $participation;
|
||||
|
||||
/**
|
||||
* Customer
|
||||
*
|
||||
* @var Customer
|
||||
*/
|
||||
private $customer;
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
* @var Settings
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* WinningProofMail
|
||||
*
|
||||
* @param string $stickerPath
|
||||
* @param string $ticketPath
|
||||
* @param string $barcodePath
|
||||
* @param Participation $participation
|
||||
* @param Customer $customer
|
||||
* @param Settings $settings
|
||||
*/
|
||||
public function __construct(
|
||||
string $stickerPath,
|
||||
string $ticketPath,
|
||||
string $barcodePath,
|
||||
Participation $participation,
|
||||
Customer $customer,
|
||||
Settings $settings
|
||||
) {
|
||||
$this->stickerPath = $stickerPath;
|
||||
$this->ticketPath = $ticketPath;
|
||||
$this->barcodePath = $barcodePath;
|
||||
$this->participation = $participation;
|
||||
$this->customer = $customer;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$participation = $this->participation;
|
||||
$customer = $this->customer;
|
||||
return $this->subject(
|
||||
$this->settings->name . " : Preuves de gain de " .
|
||||
$customer->lastname . " " . $customer->firstname
|
||||
)->view(
|
||||
'front.basic.winning-proof-email',
|
||||
compact('participation', 'customer')
|
||||
)->attach($this->stickerPath)->attach($this->ticketPath)
|
||||
->attach($this->barcodePath);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,13 @@ class CodeEan extends Model
|
|||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* Has Many Participation relationship
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function participations()
|
||||
{
|
||||
return $this->hasMany(Participation::class);
|
||||
|
|
|
|||
|
|
@ -6,4 +6,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Content extends Model
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $fillable = [
|
||||
'value'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
97
app/Models/Customer.php
Normal file
97
app/Models/Customer.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class Customer extends Authenticatable
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'crm_id',
|
||||
'civility',
|
||||
'firstname',
|
||||
'lastname',
|
||||
'birth_date',
|
||||
'email',
|
||||
'password',
|
||||
'address',
|
||||
'address2',
|
||||
'town',
|
||||
'postal_code',
|
||||
'country',
|
||||
'email_verify_token',
|
||||
'email_verified'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified' => 'boolean',
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Map attribute names to enum classes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $enumCasts = [
|
||||
'role' => UserRole::class
|
||||
];
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* Has Many Participation relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function participations()
|
||||
{
|
||||
return $this->hasMany(Participation::class, 'customer_id');
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Check if user is admin.
|
||||
* ! Not local CRM !
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is local.
|
||||
* ! Not local CRM !
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLocal(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,18 +16,36 @@ class FaqQuestion extends Model
|
|||
'negative_vote', 'theme_id'
|
||||
];
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* Belongs To FaqTheme relationship
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function theme()
|
||||
{
|
||||
return $this->belongsTo(FaqTheme::class, 'theme_id');
|
||||
}
|
||||
|
||||
public function getUtilityAttribute()
|
||||
/**
|
||||
* Get utility attribute
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getUtilityAttribute(): float
|
||||
{
|
||||
/** @var float */
|
||||
$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;
|
||||
$pourcent = ceil((1 - $ratio) * 100);
|
||||
if (
|
||||
$this->positive_vote !== null &&
|
||||
$this->negative_vote !== null &&
|
||||
$this->positive_vote >= $this->negative_vote &&
|
||||
$this->positive_vote > 0 && $this->negative_vote > 0
|
||||
) {
|
||||
$ratio = \floatval($this->negative_vote / $this->positive_vote);
|
||||
$pourcent = \floatval(ceil((1 - $ratio) * 100));
|
||||
}
|
||||
|
||||
return $pourcent;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,13 @@ class FaqTheme extends Model
|
|||
*/
|
||||
protected $with = ['questions'];
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* Has many FaqQuestion relationship
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function questions()
|
||||
{
|
||||
return $this->hasMany(FaqQuestion::class, 'theme_id');
|
||||
|
|
|
|||
|
|
@ -13,6 +13,13 @@ class GainView extends Model
|
|||
*/
|
||||
protected $fillable = ['name', 'file_name'];
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* Has many Prize relationship
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function prizes()
|
||||
{
|
||||
return $this->hasMany(Prize::class, 'gain_view_id');
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ class InstantWin extends Model
|
|||
'appear_date' => 'datetime'
|
||||
];
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* BelongsTo Prize relation
|
||||
*
|
||||
|
|
|
|||
|
|
@ -6,14 +6,16 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Participation extends Model
|
||||
{
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* BelongsTo User relation
|
||||
* BelongsTo Customer relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,18 +18,9 @@ class User extends Authenticatable
|
|||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'crm_id',
|
||||
'civility',
|
||||
'firstname',
|
||||
'lastname',
|
||||
'birth_date',
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'address',
|
||||
'address2',
|
||||
'town',
|
||||
'postal_code',
|
||||
'country',
|
||||
'email_verify_token',
|
||||
'email_verified'
|
||||
];
|
||||
|
|
@ -61,16 +52,6 @@ class User extends Authenticatable
|
|||
'role' => UserRole::class
|
||||
];
|
||||
|
||||
/**
|
||||
* Has Many Participation relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function participations()
|
||||
{
|
||||
return $this->hasMany(Participation::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is admin.
|
||||
*
|
||||
|
|
@ -83,12 +64,12 @@ class User extends Authenticatable
|
|||
|
||||
/**
|
||||
* Check if user is local.
|
||||
* ! IS local no CRM !
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLocal(): bool
|
||||
{
|
||||
return $this->role->equals(UserRole::admin()) or
|
||||
$this->role->equals(UserRole::brand());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,17 +68,14 @@ class AppServiceProvider extends ServiceProvider
|
|||
View::share('settingsGlobal', $settingsGlobal);
|
||||
|
||||
// On ramène aussi tout les prix car on en a besoin sur le header.
|
||||
$prizesGlobal = Cache::get('prizesGlobal');
|
||||
if (!$prizesGlobal) {
|
||||
$prizesGlobal = Prize::all();
|
||||
Cache::put('prizesGlobal', $prizesGlobal);
|
||||
}
|
||||
View::share('prizesGlobal', $prizesGlobal);
|
||||
View::share('prizesGlobal', Cache::remember('prizesGlobal', 60, function () {
|
||||
return Prize::all();
|
||||
}));
|
||||
|
||||
|
||||
Blade::if('superadmin', function () {
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
/** @var \App\Models\User|null $user */
|
||||
$user = auth('web')->user();
|
||||
return $user and $user->isAdmin();
|
||||
});
|
||||
}//end if
|
||||
|
|
|
|||
54
composer.lock
generated
54
composer.lock
generated
|
|
@ -1107,16 +1107,16 @@
|
|||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v8.83.4",
|
||||
"version": "v8.83.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "97a549f1a83cfb32dab1eecab4c4d40a984a72b5"
|
||||
"reference": "33b1b981266e3a19fbc826b60c4a6847e311ac95"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/97a549f1a83cfb32dab1eecab4c4d40a984a72b5",
|
||||
"reference": "97a549f1a83cfb32dab1eecab4c4d40a984a72b5",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/33b1b981266e3a19fbc826b60c4a6847e311ac95",
|
||||
"reference": "33b1b981266e3a19fbc826b60c4a6847e311ac95",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1276,7 +1276,7 @@
|
|||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"time": "2022-03-08T16:12:54+00:00"
|
||||
"time": "2022-03-15T13:37:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/serializable-closure",
|
||||
|
|
@ -1711,16 +1711,16 @@
|
|||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "2.3.5",
|
||||
"version": "2.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Seldaek/monolog.git",
|
||||
"reference": "fd4380d6fc37626e2f799f29d91195040137eba9"
|
||||
"reference": "d7fd7450628561ba697b7097d86db72662f54aef"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd4380d6fc37626e2f799f29d91195040137eba9",
|
||||
"reference": "fd4380d6fc37626e2f799f29d91195040137eba9",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/d7fd7450628561ba697b7097d86db72662f54aef",
|
||||
"reference": "d7fd7450628561ba697b7097d86db72662f54aef",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1742,7 +1742,7 @@
|
|||
"phpstan/phpstan": "^0.12.91",
|
||||
"phpunit/phpunit": "^8.5",
|
||||
"predis/predis": "^1.1",
|
||||
"rollbar/rollbar": "^1.3",
|
||||
"rollbar/rollbar": "^1.3 || ^2 || ^3",
|
||||
"ruflin/elastica": ">=0.90@dev",
|
||||
"swiftmailer/swiftmailer": "^5.3|^6.0"
|
||||
},
|
||||
|
|
@ -1794,7 +1794,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Seldaek/monolog/issues",
|
||||
"source": "https://github.com/Seldaek/monolog/tree/2.3.5"
|
||||
"source": "https://github.com/Seldaek/monolog/tree/2.4.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -1806,7 +1806,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-10-01T21:08:31+00:00"
|
||||
"time": "2022-03-14T12:44:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
|
|
@ -7085,16 +7085,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "9.5.18",
|
||||
"version": "9.5.19",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "1b5856028273bfd855e60a887278857d872ec67a"
|
||||
"reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1b5856028273bfd855e60a887278857d872ec67a",
|
||||
"reference": "1b5856028273bfd855e60a887278857d872ec67a",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/35ea4b7f3acabb26f4bb640f8c30866c401da807",
|
||||
"reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -7124,7 +7124,7 @@
|
|||
"sebastian/global-state": "^5.0.1",
|
||||
"sebastian/object-enumerator": "^4.0.3",
|
||||
"sebastian/resource-operations": "^3.0.3",
|
||||
"sebastian/type": "^2.3.4",
|
||||
"sebastian/type": "^3.0",
|
||||
"sebastian/version": "^3.0.2"
|
||||
},
|
||||
"require-dev": {
|
||||
|
|
@ -7172,7 +7172,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.18"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.19"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -7184,7 +7184,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-03-08T06:52:28+00:00"
|
||||
"time": "2022-03-15T09:57:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
|
@ -8043,28 +8043,28 @@
|
|||
},
|
||||
{
|
||||
"name": "sebastian/type",
|
||||
"version": "2.3.4",
|
||||
"version": "3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/type.git",
|
||||
"reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914"
|
||||
"reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914",
|
||||
"reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad",
|
||||
"reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.3"
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3-dev"
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
|
@ -8087,7 +8087,7 @@
|
|||
"homepage": "https://github.com/sebastianbergmann/type",
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/type/issues",
|
||||
"source": "https://github.com/sebastianbergmann/type/tree/2.3.4"
|
||||
"source": "https://github.com/sebastianbergmann/type/tree/3.0.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -8095,7 +8095,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-06-15T12:49:02+00:00"
|
||||
"time": "2022-03-15T09:54:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/version",
|
||||
|
|
|
|||
|
|
@ -41,11 +41,10 @@ return [
|
|||
'provider' => 'users',
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'driver' => 'token',
|
||||
'provider' => 'users',
|
||||
'hash' => false,
|
||||
],
|
||||
'customer' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'customers',
|
||||
]
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
@ -70,6 +69,11 @@ return [
|
|||
'driver' => 'eloquent',
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
|
||||
'customers' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\Customer::class,
|
||||
]
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
@ -89,7 +93,7 @@ return [
|
|||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'provider' => 'customers',
|
||||
'table' => 'password_resets',
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
|
|
|
|||
|
|
@ -15,22 +15,10 @@ class CreateUsersTable extends Migration
|
|||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('crm_id')->nullable();
|
||||
$table->string('firstname');
|
||||
$table->string('lastname');
|
||||
$table->date('birth_date')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->string('address')->nullable();
|
||||
$table->string('address2')->nullable();
|
||||
$table->string('town')->nullable();
|
||||
$table->string('postal_code')->nullable();
|
||||
$table->string('country')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->string('email_verify_token')->nullable();
|
||||
$table->boolean('email_verified')->default(0);
|
||||
$table->string('password_token')->nullable();
|
||||
$table->integer('role')->default(3);
|
||||
$table->integer('role')->default(2);
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCustomersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('customers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('firstname');
|
||||
$table->string('lastname');
|
||||
$table->date('birth_date')->nullable();
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->string('address')->nullable();
|
||||
$table->string('address2')->nullable();
|
||||
$table->string('town')->nullable();
|
||||
$table->string('postal_code')->nullable();
|
||||
$table->string('country')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->string('email_verify_token')->nullable();
|
||||
$table->boolean('email_verified')->default(0);
|
||||
$table->string('password_token')->nullable();
|
||||
$table->integer('crm_id')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('customers');
|
||||
}
|
||||
}
|
||||
|
|
@ -15,8 +15,7 @@ class CreateBannedIps extends Migration
|
|||
{
|
||||
Schema::create('banned_ips', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('ip');
|
||||
$table->unique('ip');
|
||||
$table->string('ip')->unique();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class CreateParticipations extends Migration
|
|||
$table->string('sticker')->nullable();
|
||||
$table->string('ticket')->nullable();
|
||||
$table->string('barcode')->nullable();
|
||||
$table->foreignId('user_id')->constrained('users');
|
||||
$table->foreignId('customer_id')->constrained('customers');
|
||||
$table->foreignId('code_unique_id')->constrained('codes');
|
||||
$table->foreignId('code_ean_id')->nullable()->constrained('code_eans');
|
||||
$table->foreignId('reduction_id')->nullable()->constrained('reductions');
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class PrizeSeeder extends Seeder
|
|||
$gainview->save();
|
||||
|
||||
$prize = new Prize();
|
||||
$prize->arcadia_id = 0;
|
||||
$prize->arcadia_id = 1;
|
||||
$prize->label_one = 'Lot ';
|
||||
$prize->label_many = 'Lots 2';
|
||||
$prize->quantity = 2;
|
||||
|
|
|
|||
10941
public/css/app.css
vendored
10941
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
103205
public/js/app.js
vendored
103205
public/js/app.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -40,7 +40,7 @@
|
|||
<tbody>
|
||||
<tr v-for="item in displayedips" v-bind:key="item.id">
|
||||
<td><input class="form-control form-control-sm" v-model="item.ip" type="text" disabled></td>
|
||||
<td><button @click="removeItem(item.ip)" class="btn btn-dangerbtn-sm">Supprimer</button></td>
|
||||
<td><button @click="removeItem(item.ip)" class="btn btn-danger btn-sm">Supprimer</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -125,9 +125,8 @@
|
|||
if (i !== null && this.baseDatas[i]['ip'] !== null) {
|
||||
axios.post('/bo/ajax/delete-banned-ip', {
|
||||
ip: this.baseDatas[i]['ip'],
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
}).catch(function (error) {
|
||||
console.error(error);
|
||||
});
|
||||
this.baseDatas.splice(i, 1);
|
||||
this.datas.splice(iDatas, 1);
|
||||
|
|
@ -139,23 +138,27 @@
|
|||
},
|
||||
// Sauvegarde les données dans la base
|
||||
saveData() {
|
||||
this.processing = true;
|
||||
this.response = "En cours de sauvegarde...";
|
||||
this.searchText = '';
|
||||
let self = this
|
||||
self.processing = true;
|
||||
self.response = "En cours de sauvegarde...";
|
||||
self.searchText = '';
|
||||
axios.post('/bo/ajax/save-banned-ip', {
|
||||
ips: this.baseDatas,
|
||||
ips: self.ipList
|
||||
}).then(
|
||||
(response) => {
|
||||
this.datas = response.data;
|
||||
this.baseDatas = JSON.parse(JSON.stringify(this.datas));
|
||||
this.response = "Sauvegarde terminée !";
|
||||
this.processing = false;
|
||||
self.datas = response.data;
|
||||
self.baseDatas = JSON.parse(JSON.stringify(self.datas));
|
||||
self.response = "Sauvegarde terminée !";
|
||||
self.processing = false;
|
||||
}
|
||||
).catch(function (error) {
|
||||
console.error(error);
|
||||
self.response = "Erreur lors de la sauvegarde.";
|
||||
self.processing = false;
|
||||
let messages = Object.values(error?.response?.data?.errors ?? {})
|
||||
if(Array.isArray(messages)) {
|
||||
alert(messages.join(','))
|
||||
}
|
||||
)
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
this.response = "Erreur lors de la sauvegarde.";
|
||||
this.processing = false;
|
||||
});
|
||||
},
|
||||
// Calcul le nombre de page total dans la pagination
|
||||
|
|
@ -214,6 +217,13 @@
|
|||
computed: {
|
||||
displayedips () {
|
||||
return this.paginate(this.datas);
|
||||
},
|
||||
ipList () {
|
||||
let ipList = [];
|
||||
for(let ip of this.datas) {
|
||||
ipList.push(ip.ip)
|
||||
}
|
||||
return ipList;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
{{ ucfirst($content->key) }}
|
||||
</div>
|
||||
|
||||
<form action="{{route('bo.content', $content->id)}}" method="POST">
|
||||
<form action="{{route('bo.contents.manageSubmit', $content)}}" method="POST">
|
||||
@method('PUT')
|
||||
@csrf
|
||||
<div class="card-body">
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<hr>
|
||||
<p>
|
||||
Nombre de participations total : <b>{{ $totalParticipation }}</b><br>
|
||||
Nombre de participations moyenne par joueur : <b>{{ $avgParticipUser }}</b><br>
|
||||
Nombre de participations moyenne par joueur : <b>{{ $avgParticipCustomer }}</b><br>
|
||||
@if ($settings->use_ean_codes)
|
||||
Top 3 des codes EAN les plus utilisés :
|
||||
<ul class="list-group list-group-horizontal">
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Envoyer le courrier à Arcadia pour {{ $participation->user->lastname }} {{ $participation->user->firstname }}
|
||||
Envoyer le courrier à Arcadia pour {{ $participation->customer->lastname }} {{ $participation->customer->firstname }}
|
||||
<a href="{{ route('bo.winners-list') }}" class="btn btn-sm btn-primary float-right">Retour</a>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -24,33 +24,33 @@
|
|||
<th scope="col">Arcadia</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($winnersList as $winner)
|
||||
@foreach($winnersList as $participation)
|
||||
<tr>
|
||||
<td>{{ \Carbon\Carbon::parse($winner->created_at)->format('d/m/Y à H:i') }}</td>
|
||||
<td>{{$winner->instantWin->prize->label_one}}</td>
|
||||
<td>{{$winner->user->email}}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($participation->created_at)->format('d/m/Y à H:i') }}</td>
|
||||
<td>{{$participation->instantWin->prize->label_one}}</td>
|
||||
<td>{{$participation->customer->email}}</td>
|
||||
@if ($settings->use_ean_codes)
|
||||
<td>{{$winner->code_ean}}</td>
|
||||
<td>{{$participation->code_ean}}</td>
|
||||
@endif
|
||||
<td>{{$winner->code->code_unique}}</td>
|
||||
<td>{{$participation->code->code_unique}}</td>
|
||||
@if ($settings->winning_proof === 1)
|
||||
@if ($winner->sticker !== null)
|
||||
<td class="text-center"><a href="/fichiers/preuve-de-gain/{{$winner->id}}/{{$winner->sticker}}" class="btn btn-success btn-sm" target="_blank">Voir</a></td>
|
||||
@if ($participation->sticker !== null)
|
||||
<td class="text-center"><a href="/fichiers/preuve-de-gain/{{$participation->id}}/{{$participation->sticker}}" class="btn btn-success btn-sm" target="_blank">Voir</a></td>
|
||||
@else
|
||||
<td class="text-center">-</td>
|
||||
@endif
|
||||
@if ($winner->barcode !== null)
|
||||
<td class="text-center"><a href="/fichiers/preuve-de-gain/{{$winner->id}}/{{$winner->barcode}}" class="btn btn-success btn-sm" target="_blank">Voir</a></td>
|
||||
@if ($participation->barcode !== null)
|
||||
<td class="text-center"><a href="/fichiers/preuve-de-gain/{{$participation->id}}/{{$participation->barcode}}" class="btn btn-success btn-sm" target="_blank">Voir</a></td>
|
||||
@else
|
||||
<td class="text-center">-</td>
|
||||
@endif
|
||||
@if ($winner->ticket !== null)
|
||||
<td class="text-center"><a href="/fichiers/preuve-de-gain/{{$winner->id}}/{{$winner->ticket}}" class="btn btn-success btn-sm" target="_blank">Voir</a></td>
|
||||
@if ($participation->ticket !== null)
|
||||
<td class="text-center"><a href="/fichiers/preuve-de-gain/{{$participation->id}}/{{$participation->ticket}}" class="btn btn-success btn-sm" target="_blank">Voir</a></td>
|
||||
@else
|
||||
<td class="text-center">-</td>
|
||||
@endif
|
||||
@endif
|
||||
<td><a href="{{ route('bo.winners-arcadia', $winner->id) }}" class="btn btn-sm btn-primary">Envoyer</a></td>
|
||||
<td><a href="{{ route('bo.winners-arcadia', $participation->id) }}" class="btn btn-sm btn-primary">Envoyer</a></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<!-- Pour afficher un seul lot, remplacer le [0] par [1], [2], etc. -->
|
||||
@if (isset($prizesGlobal[0]))
|
||||
{{$prizesGlobal[0]->label_one}}
|
||||
@if ($prizesGlobal->get(0))
|
||||
{{ $prizesGlobal->get(0)->label_one }}
|
||||
@endif
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@
|
|||
<!-- Right Side Of Navbar -->
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<!-- Authentication Links -->
|
||||
@guest
|
||||
@guest('customer')
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{route('login')}}">Connexion</a>
|
||||
</li>
|
||||
@else
|
||||
<li class="nav-item dropdown">
|
||||
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
|
||||
Bonjour {{ Auth::user()->firstname }} <span class="caret"></span>
|
||||
Bonjour {{ auth('customer')->user()->firstname }} <span class="caret"></span>
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@
|
|||
<p>Bonjour,</p>
|
||||
<p>Le lot suivant a été gagné : <b>{{ $participation->instantWin->prize->label_one}}</b> le {{ \Carbon\Carbon::parse($participation->created_at)->format('d/m/Y à H:i') }}</p><br>
|
||||
<p><b>Gagnant :</b></p>
|
||||
<p>{{ $participation->user->lastname }} {{ $participation->user->firstname }}</p>
|
||||
<p>{{ $participation->user->address }}</p>
|
||||
@if ($participation->user->address2 !== null)
|
||||
<p>{{ $participation->user->address2 }}</p>
|
||||
<p>{{ $participation->customer->lastname }} {{ $participation->customer->firstname }}</p>
|
||||
<p>{{ $participation->customer->address }}</p>
|
||||
@if ($participation->customer->address2 !== null)
|
||||
<p>{{ $participation->customer->address2 }}</p>
|
||||
@endif
|
||||
<p>{{ $participation->user->postal_code }} {{ $participation->user->town }} - {{ $participation->user->country }}</p>
|
||||
<p>{{ $participation->user->email }}</p><br/>
|
||||
<p>{{ $participation->customer->postal_code }} {{ $participation->customer->town }} - {{ $participation->customer->country }}</p>
|
||||
<p>{{ $participation->customer->email }}</p><br/>
|
||||
<p><b>Codes utilisé@if (isset($participation->code_ean))s @endif :</b></p>
|
||||
@if (isset($participation->code_ean))
|
||||
<p>- Code On Pack : {{ $participation->code_ean }}</p>
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
<p>Vous trouverez en PJ les preuves de gain du joueur suivant :</p>
|
||||
<p>
|
||||
<b>Lot : {{$prize->label_one ?? ''}}</b><br/>
|
||||
{{Auth::user()->lastname}} {{Auth::user()->firstname}}<br/>
|
||||
{{Auth::user()->address}}<br/>
|
||||
@if (Auth::user()->address2 !== null)
|
||||
{{Auth::user()->address2}}<br/>
|
||||
{{auth('customer')->user()->lastname}} {{auth('customer')->user()->firstname}}<br/>
|
||||
{{auth('customer')->user()->address}}<br/>
|
||||
@if (auth('customer')->user()->address2 !== null)
|
||||
{{auth('customer')->user()->address2}}<br/>
|
||||
@endif
|
||||
{{Auth::user()->postal_code}} {{Auth::user()->town}} - {{Auth::user()->country}}<br/>
|
||||
{{Auth::user()->email}}
|
||||
{{auth('customer')->user()->postal_code}} {{auth('customer')->user()->town}} - {{auth('customer')->user()->country}}<br/>
|
||||
{{auth('customer')->user()->email}}
|
||||
</p>
|
||||
<p>Codes utilisés :</p>
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -17,25 +17,25 @@
|
|||
</div>
|
||||
@endif
|
||||
<div class="form-group">
|
||||
<input type="text" name="lastname" class="form-control" placeholder="Nom *" value="{{ Auth::user()->lastname }}" required>
|
||||
<input type="text" name="lastname" class="form-control" placeholder="Nom *" value="{{ auth('customer')->user()->lastname }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="firstname" class="form-control" placeholder="Prénom *" value="{{ Auth::user()->firstname }}" required>
|
||||
<input type="text" name="firstname" class="form-control" placeholder="Prénom *" value="{{ auth('customer')->user()->firstname }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="address" class="form-control" placeholder="Adresse *" value="{{ Auth::user()->address }}" required>
|
||||
<input type="text" name="address" class="form-control" placeholder="Adresse *" value="{{ auth('customer')->user()->address }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="address2" class="form-control" placeholder="Adresse complémentaire" value="{{ Auth::user()->address2 }}">
|
||||
<input type="text" name="address2" class="form-control" placeholder="Adresse complémentaire" value="{{ auth('customer')->user()->address2 }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="town" class="form-control" placeholder="Ville *" value="{{ Auth::user()->town }}" required>
|
||||
<input type="text" name="town" class="form-control" placeholder="Ville *" value="{{ auth('customer')->user()->town }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="postal_code" class="form-control" placeholder="Code postal *" value="{{ Auth::user()->postal_code }}" required>
|
||||
<input type="text" name="postal_code" class="form-control" placeholder="Code postal *" value="{{ auth('customer')->user()->postal_code }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="country" class="form-control" placeholder="Pays *" value="{{ Auth::user()->country }}" required>
|
||||
<input type="text" name="country" class="form-control" placeholder="Pays *" value="{{ auth('customer')->user()->country }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="phone" class="form-control" placeholder="Téléphone *" required>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
<!-- Right Side Of Navbar -->
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<!-- Authentication Links -->
|
||||
@guest
|
||||
@guest('customer')
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
|
||||
</li>
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
@else
|
||||
<li class="nav-item dropdown">
|
||||
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
|
||||
{{ Auth::user()->name }}
|
||||
{{ auth('customer')->user()->name }}
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@
|
|||
<!-- Right Side Of Navbar -->
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<!-- Authentication Links -->
|
||||
@auth
|
||||
@auth('web')
|
||||
<li class="nav-item dropdown">
|
||||
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
|
||||
Bonjour {{ Auth::user()->firstname }} <span class="caret"></span>
|
||||
Bonjour {{ auth('web')->user()->name }} <span class="caret"></span>
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
|
||||
|
|
@ -96,9 +96,9 @@
|
|||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Contenus</a>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="{{route('bo.content', 1)}}">Mentions légales</a>
|
||||
<a class="dropdown-item" href="{{route('bo.content', 2)}}">Charte</a>
|
||||
<a class="dropdown-item" href="{{route('bo.content', 3)}}">Règlement</a>
|
||||
<a class="dropdown-item" href="{{route('bo.contents.manage', \App\Enums\ContentPageType::legals())}}">{{ \App\Enums\ContentPageType::legals()->label }}</a>
|
||||
<a class="dropdown-item" href="{{route('bo.contents.manage', \App\Enums\ContentPageType::charte())}}">{{ \App\Enums\ContentPageType::charte()->label }}</a>
|
||||
<a class="dropdown-item" href="{{route('bo.contents.manage', \App\Enums\ContentPageType::reglement())}}">{{ \App\Enums\ContentPageType::reglement()->label }}</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
|
|
|
|||
|
|
@ -1,100 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>Laravel</title>
|
||||
|
||||
<!-- Fonts -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
|
||||
|
||||
<!-- Styles -->
|
||||
<style>
|
||||
html, body {
|
||||
background-color: #fff;
|
||||
color: #636b6f;
|
||||
font-family: 'Nunito', sans-serif;
|
||||
font-weight: 200;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.full-height {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.flex-center {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.position-ref {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.top-right {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 18px;
|
||||
}
|
||||
|
||||
.content {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 84px;
|
||||
}
|
||||
|
||||
.links > a {
|
||||
color: #636b6f;
|
||||
padding: 0 25px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
letter-spacing: .1rem;
|
||||
text-decoration: none;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.m-b-md {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="flex-center position-ref full-height">
|
||||
@if (Route::has('login'))
|
||||
<div class="top-right links">
|
||||
@auth
|
||||
<a href="{{ url('/home') }}">Home</a>
|
||||
@else
|
||||
<a href="{{ route('login') }}">Login</a>
|
||||
|
||||
@if (Route::has('register'))
|
||||
<a href="{{ route('register') }}">Register</a>
|
||||
@endif
|
||||
@endauth
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="content">
|
||||
<div class="title m-b-md">
|
||||
Laravel
|
||||
</div>
|
||||
|
||||
<div class="links">
|
||||
<a href="https://laravel.com/docs">Docs</a>
|
||||
<a href="https://laracasts.com">Laracasts</a>
|
||||
<a href="https://laravel-news.com">News</a>
|
||||
<a href="https://blog.laravel.com">Blog</a>
|
||||
<a href="https://nova.laravel.com">Nova</a>
|
||||
<a href="https://forge.laravel.com">Forge</a>
|
||||
<a href="https://vapor.laravel.com">Vapor</a>
|
||||
<a href="https://github.com/laravel/laravel">GitHub</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,12 +1 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register API routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| is assigned the "api" middleware group. Enjoy building your API!
|
||||
|
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,18 +1 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Broadcast Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may register all of the event broadcasting channels that your
|
||||
| application supports. The given channel authorization callbacks are
|
||||
| used to check if an authenticated user can listen to the channel.
|
||||
|
|
||||
*/
|
||||
|
||||
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
||||
return (int)$user->id === (int)$id;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,19 +1 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Console Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is where you may define all of your Closure based console
|
||||
| commands. Each Closure is bound to a command instance allowing a
|
||||
| simple approach to interacting with each command's IO methods.
|
||||
|
|
||||
*/
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->describe('Display an inspiring quote');
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Illuminate\Support\Facades\Route;
|
|||
// * BO
|
||||
Route::prefix('bo')
|
||||
->name('bo.')
|
||||
->middleware(['auth', 'is-admin', 'is-super-admin'])
|
||||
->middleware(['auth:web', 'is-admin', 'is-super-admin'])
|
||||
->group(function () {
|
||||
Route::get('/', [DashboardController::class, 'index'])
|
||||
->name('dashboard')->withoutMiddleware('is-super-admin');
|
||||
|
|
@ -27,8 +27,8 @@ Route::prefix('bo')
|
|||
Route::get('/settings', [SettingsController::class, 'manage'])->name('settings');
|
||||
Route::put('/settings', [SettingsController::class, 'manageSubmit'])->name('settingsSubmit');
|
||||
// Contenu.
|
||||
Route::match(['get', 'put'], '/content/{id}', [ContentController::class, 'manage'])
|
||||
->name('content');
|
||||
Route::get('/content/{content}', [ContentController::class, 'manage'])->name('contents.manage');
|
||||
Route::put('/content/{content}', [ContentController::class, 'manageSubmit'])->name('contents.manageSubmit');
|
||||
// Pages liées au gains.
|
||||
Route::get('/gain-views', [GainViewController::class, 'index'])
|
||||
->name('gain-views');
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\EndPageController;
|
||||
use App\Http\Controllers\EnterCodeController;
|
||||
use App\Http\Controllers\FAQController;
|
||||
use App\Http\Controllers\GainsController;
|
||||
use App\Http\Controllers\HomeController;
|
||||
use App\Http\Controllers\HowToPlayController;
|
||||
use App\Http\Controllers\LoginController;
|
||||
use App\Http\Controllers\ProduitsController;
|
||||
use App\Http\Controllers\RegisterController;
|
||||
use App\Http\Controllers\TeaserController;
|
||||
use App\Http\Controllers\ViewContentController;
|
||||
use App\Http\Controllers\WinningProofController;
|
||||
use App\Http\Controllers\Fo\EndPageController;
|
||||
use App\Http\Controllers\Fo\EnterCodeController;
|
||||
use App\Http\Controllers\Fo\FAQController;
|
||||
use App\Http\Controllers\Fo\GainsController;
|
||||
use App\Http\Controllers\Fo\HomeController;
|
||||
use App\Http\Controllers\Fo\HowToPlayController;
|
||||
use App\Http\Controllers\Fo\LoginController;
|
||||
use App\Http\Controllers\Fo\ProduitsController;
|
||||
use App\Http\Controllers\Fo\RegisterController;
|
||||
use App\Http\Controllers\Fo\TeaserController;
|
||||
use App\Http\Controllers\Fo\ViewContentController;
|
||||
use App\Http\Controllers\Fo\WinningProofController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['middleware' => ['game-date']], function () {
|
||||
|
|
@ -32,22 +32,23 @@ Route::group(['middleware' => ['game-date']], function () {
|
|||
Route::put('/change-mot-de-passe', [LoginController::class, 'changePassword'])->name('change-password');
|
||||
|
||||
// Front nécessitant d'être connecté.
|
||||
Route::get('/saisir-code', [EnterCodeController::class, 'index'])->name('saisir-code')->middleware('auth');
|
||||
Route::post('/saisir-code', [EnterCodeController::class, 'participate'])
|
||||
->name('participate')->middleware('auth');
|
||||
Route::put('/saisir-code', [EnterCodeController::class, 'formWinningProof'])
|
||||
->name('winning-proof')->middleware('auth');
|
||||
Route::put('/rejouer', [WinningProofController::class, 'sendWinningProof'])
|
||||
->name('send-winning-proof')->middleware('auth');
|
||||
Route::middleware('auth:customer')->group(function () {
|
||||
Route::get('/saisir-code', [EnterCodeController::class, 'index'])->name('saisir-code');
|
||||
Route::post('/saisir-code', [EnterCodeController::class, 'participate'])->name('participate');
|
||||
Route::put('/saisir-code', [EnterCodeController::class, 'formWinningProof'])->name('winning-proof');
|
||||
Route::put('/rejouer', [WinningProofController::class, 'sendWinningProof'])->name('send-winning-proof');
|
||||
Route::post('/logout', [LoginController::class, 'logout'])->name('logout');
|
||||
});
|
||||
|
||||
// Authentification.
|
||||
Route::post('/logout', [LoginController::class, 'logout'])->name('logout')->middleware('auth');
|
||||
Route::get('/inscription', [RegisterController::class, 'index'])->name('inscription');
|
||||
Route::post('/inscription', [RegisterController::class, 'register'])->name('register');
|
||||
Route::middleware('guest:customer')->group(function () {
|
||||
Route::get('/inscription', [RegisterController::class, 'register'])->name('inscription');
|
||||
Route::post('/inscription', [RegisterController::class, 'registerSubmit'])->name('register');
|
||||
});
|
||||
});
|
||||
|
||||
// Login sans middleware pour la connexion admin, teaser et end pour ne pas redirigé en boucle.
|
||||
Route::get('/login', [LoginController::class, 'index'])->name('login');
|
||||
Route::post('/login', [LoginController::class, 'authenticate'])->name('authenticate');
|
||||
Route::get('/login', [LoginController::class, 'loginForm'])->name('login');
|
||||
Route::post('/login', [LoginController::class, 'loginFormSubmit'])->name('authenticate');
|
||||
Route::get('/teaser', [TeaserController::class, 'index'])->name('teaser');
|
||||
Route::get('/fin-du-jeu', [EndPageController::class, 'index'])->name('end');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue