Compare commits

..

1 commit

Author SHA1 Message Date
Jérémy
bcf9c7d54c Edit sprint.md 2026-10-08 16:25:52 +02:00
80 changed files with 3614 additions and 3728 deletions

View file

@ -1,13 +1,13 @@
include: include:
- project: "ldc-web/shared-ci" - project: "ldc-web/shared-ci"
ref: "main" ref: "main"
file: "lint/lint.yml" file: "lint/lint7.3.yml"
- project: "ldc-web/shared-ci" - project: "ldc-web/shared-ci"
ref: "main" ref: "main"
file: "security/security.yml" file: "security/security7.3.yml"
- project: "ldc-web/shared-ci" - project: "ldc-web/shared-ci"
ref: "main" ref: "main"
file: "build/build.yml" file: "build/build7.3.yml"
- project: "ldc-web/shared-ci" - project: "ldc-web/shared-ci"
ref: "main" ref: "main"
file: "test/test.yml" file: "test/test.yml"

View file

@ -1,7 +1,7 @@
👤 **Formulation** 👤 **Formulation**
<!-- réferencer des labels avec tilde ~ --> <!-- réferencer des labels avec tilde ~ -->
**En tant que** ~"persona:: Marie" **En tant que** ~"::persona Marie"
**Je veux** <!-- action / fonctionnalité souhaitée en utilisant les objets métier entre backticks (ex: `Brand`, `Campaign`) --> **Je veux** <!-- action / fonctionnalité souhaitée en utilisant les objets métier entre backticks (ex: `Brand`, `Campaign`) -->

View file

@ -1,5 +1,4 @@
ARG PHP_8_5_TAG=latest FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/ldcweb-production-7.3:060825-070701
FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/uwil-production-8.5:${PHP_8_5_TAG}
COPY --chown=www-data:www-data . /app/srcs COPY --chown=www-data:www-data . /app/srcs
USER root USER root
RUN chmod -R 755 /app/srcs/storage RUN chmod -R 755 /app/srcs/storage

View file

@ -15,7 +15,6 @@ class ArchiveStatsCommand extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'uwil:stats:archive'; protected $signature = 'uwil:stats:archive';
/** /**
@ -23,7 +22,6 @@ class ArchiveStatsCommand extends Command
* *
* @var string * @var string
*/ */
protected $description = 'Archives mesbr stats'; protected $description = 'Archives mesbr stats';
/** /**
@ -36,7 +34,7 @@ class ArchiveStatsCommand extends Command
$baseArchiveStatCount = ArchiveStat::count(); $baseArchiveStatCount = ArchiveStat::count();
$baseStatCount = Statistique::count(); $baseStatCount = Statistique::count();
new ArchiveStatsJob()->handle(); (new ArchiveStatsJob())->handle();
$this->info(sprintf( $this->info(sprintf(
'%s archive(s) created', '%s archive(s) created',

View file

@ -19,7 +19,6 @@ class CustomersClaims extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'customers:claims {--siteId=?} {destCampaignId} {destCouponId}'; protected $signature = 'customers:claims {--siteId=?} {destCampaignId} {destCouponId}';
/** /**
@ -27,7 +26,6 @@ class CustomersClaims extends Command
* *
* @var string * @var string
*/ */
protected $description = 'Command description'; protected $description = 'Command description';
/** /**
@ -60,20 +58,30 @@ class CustomersClaims extends Command
Site::all(['id', 'site_id', 'site_nom'])->toArray() Site::all(['id', 'site_id', 'site_nom'])->toArray()
); );
$site = $this->validateInput(fn() => $this->ask('Enter site model id'), 'required|numeric|min:1|max:50|exists:site,id'); $site = $this->validateInput(function () {
return $this->ask('Enter site model id');
}, 'required|numeric|min:1|max:50|exists:site,id');
$site = Site::find($site); $site = Site::find($site);
} else { } else {
$site = Site::find($siteIdArg); $site = Site::find($siteIdArg);
} }
$email = $this->validateInput(fn() => $this->ask('Enter customer email'), 'required|email|min:1|max:255'); $email = $this->validateInput(function () {
return $this->ask('Enter customer email');
}, 'required|email|min:1|max:255');
$crmHashcode = $this->validateInput(fn() => $this->ask('Enter customer hashcode'), 'required|string|min:1|max:36'); $crmHashcode = $this->validateInput(function () {
return $this->ask('Enter customer hashcode');
}, 'required|string|min:1|max:36');
$crmCountry = $this->validateInput(fn() => $this->ask('Enter customer country ISO code'), 'required|numeric|in:56,250,442'); $crmCountry = $this->validateInput(function () {
return $this->ask('Enter customer country ISO code');
}, 'required|numeric|in:56,250,442');
$date = $this->validateInput(fn() => $this->ask('Enter claim date'), 'required|date_format:d/m/Y'); $date = $this->validateInput(function () {
return $this->ask('Enter claim date');
}, 'required|date_format:d/m/Y');
$contacts = Contact::where('contact_email', $email) $contacts = Contact::where('contact_email', $email)
->where('contact_siteId', '=', $site->site_id) ->where('contact_siteId', '=', $site->site_id)
@ -81,7 +89,7 @@ class CustomersClaims extends Command
$toAdd = 0; $toAdd = 0;
foreach ($contacts as $contact) { foreach ($contacts as $contact) {
$claimDate = \Illuminate\Support\Facades\Date::createFromFormat('d/m/Y', $date)->format('Y-m-d'); $claimDate = Carbon::createFromFormat('d/m/Y', $date)->format('Y-m-d');
// On vient chercher les paniers dont la date de création est >= à la date de la récla // On vient chercher les paniers dont la date de création est >= à la date de la récla
$paniers = $contact->paniers()->where('panier_createdate', '>=', $claimDate)->get(); $paniers = $contact->paniers()->where('panier_createdate', '>=', $claimDate)->get();
foreach ($paniers as $panier) { foreach ($paniers as $panier) {
@ -91,7 +99,9 @@ class CustomersClaims extends Command
} }
} }
$qty = $this->validateInput(fn() => $this->ask('Enter quantity to add', $toAdd), 'required|numeric|max:20'); $qty = $this->validateInput(function () use ($toAdd) {
return $this->ask('Enter quantity to add', $toAdd);
}, 'required|numeric|max:20');
$customer = Customers::firstOrNew([ $customer = Customers::firstOrNew([
'hashcode' => $crmHashcode, 'hashcode' => $crmHashcode,

View file

@ -16,7 +16,6 @@ class RegenBRBase extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'coupons:regen-base'; protected $signature = 'coupons:regen-base';
/** /**
@ -24,7 +23,6 @@ class RegenBRBase extends Command
* *
* @var string * @var string
*/ */
protected $description = 'Re-generate coupons base image'; protected $description = 'Re-generate coupons base image';
/** /**

View file

@ -45,19 +45,19 @@ class Kernel extends ConsoleKernel
$schedule->job(CleanOldDatasJob::class)->daily(); $schedule->job(CleanOldDatasJob::class)->daily();
// ---- Commande d'alerte appelé tt les jours de la semaine a 7h00 // ---- Commande d'alerte appelé tt les jours de la semaine a 7h00
$schedule->call(function (): void { $schedule->call(function () {
$sites = Site::all(); $sites = Site::all();
$couponSeuilGlobal = []; $couponSeuilGlobal = array();
$couponDiffusionGlobal = []; $couponDiffusionGlobal = array();
$sendGlobal = false; $sendGlobal = false;
foreach ($sites as $site) { foreach ($sites as $site) {
// ---- Pour chaque site // ---- Pour chaque site
$campagnes = Campagne::where(['camp_siteId' => $site->site_id])->get(); $campagnes = Campagne::where(['camp_siteId' => $site->site_id])->get();
foreach ($campagnes as $campagne) { foreach ($campagnes as $campagne) {
$sendMail = false; $sendMail = false;
$users = []; $users = array();
$couponSeuil = []; $couponSeuil = array();
$couponDiffusion = []; $couponDiffusion = array();
$coupons = $campagne->coupons()->get(); $coupons = $campagne->coupons()->get();
foreach ($coupons as $coupon) { foreach ($coupons as $coupon) {
$couponAlert = false; $couponAlert = false;
@ -100,7 +100,7 @@ class Kernel extends ConsoleKernel
} //end foreach } //end foreach
} //end foreach } //end foreach
if ($sendGlobal) { if ($sendGlobal) {
$superadmins = []; $superadmins = array();
$admins = User::where(['roles' => 'superadmin'])->get(); $admins = User::where(['roles' => 'superadmin'])->get();
foreach ($admins as $admin) { foreach ($admins as $admin) {
$adminObject = []; $adminObject = [];

View file

@ -21,7 +21,6 @@ class Handler extends ExceptionHandler
* *
* @var array<int, class-string<\Throwable>> * @var array<int, class-string<\Throwable>>
*/ */
protected $dontReport = []; protected $dontReport = [];
/** /**
@ -29,7 +28,6 @@ class Handler extends ExceptionHandler
* *
* @var array<int, string> * @var array<int, string>
*/ */
protected $dontFlash = [ protected $dontFlash = [
'current_password', 'current_password',
'password', 'password',
@ -43,9 +41,9 @@ class Handler extends ExceptionHandler
*/ */
public function register() public function register()
{ {
$this->reportable(function (Throwable $e): void { $this->reportable(function (Throwable $e) {
if (app()->bound('sentry')) { if (app()->bound('sentry')) {
resolve('sentry')->captureException($e); app('sentry')->captureException($e);
} }
}); });
} }

View file

@ -101,7 +101,7 @@ class AjaxController extends Controller
$log->log_refsite = $campagne->camp_siteId; $log->log_refsite = $campagne->camp_siteId;
$log->log_params = json_encode(['refcamp' => $campagne->camp_id]); $log->log_params = json_encode(['refcamp' => $campagne->camp_id]);
$couponsPrinted = []; $couponsPrinted = array();
$coupons = '<TABLE width="100%" align="center" cellpadding="0" cellspacing="0" border="0">'; $coupons = '<TABLE width="100%" align="center" cellpadding="0" cellspacing="0" border="0">';
$coupons .= '<TR><TD width="100%" align="center"><div>'; $coupons .= '<TR><TD width="100%" align="center"><div>';
@ -113,7 +113,7 @@ class AjaxController extends Controller
} }
$nbCoupon = 0; $nbCoupon = 0;
foreach ($couponsToPrint as $coupon_code) { foreach ($couponsToPrint as $key => $coupon_code) {
$cp = Coupon::where(['coupon_code' => $coupon_code])->first(); $cp = Coupon::where(['coupon_code' => $coupon_code])->first();
if ($this->isAvailable($cp, $campagne, $contact) && $this->isAvailableToPrint($cp, $campagne)) { if ($this->isAvailable($cp, $campagne, $contact) && $this->isAvailableToPrint($cp, $campagne)) {
@ -233,7 +233,7 @@ class AjaxController extends Controller
if (!isset($panier)) { if (!isset($panier)) {
die(); die();
} }
foreach ($couponsToPrint as $coupon_code) { foreach ($couponsToPrint as $key => $coupon_code) {
$cp = Coupon::where(['coupon_code' => $coupon_code])->first(); $cp = Coupon::where(['coupon_code' => $coupon_code])->first();
if ($this->isAvailable($cp, $campagne, $contact) && $this->isAvailableToPrint($cp, $campagne)) { if ($this->isAvailable($cp, $campagne, $contact) && $this->isAvailableToPrint($cp, $campagne)) {

View file

@ -51,7 +51,7 @@ class PanierController extends Controller
if (isset($request->panier) && $request->panier != "") { if (isset($request->panier) && $request->panier != "") {
$panier = $request->panier; $panier = $request->panier;
$panierTab = explode(",", $panier); $panierTab = explode(",", $panier);
$coupons = []; $coupons = array();
foreach ($panierTab as $panier) { foreach ($panierTab as $panier) {
$pos = strpos($panier, ")"); $pos = strpos($panier, ")");
if ($pos === false || substr_count($panier, ")") != 1) { if ($pos === false || substr_count($panier, ")") != 1) {
@ -88,7 +88,7 @@ class PanierController extends Controller
} }
}//end foreach }//end foreach
// ---- Préparation message de log avec coupons // ---- Préparation message de log avec coupons
$panierCoupons = []; $panierCoupons = array();
foreach ($coupons as $code => $qty) { foreach ($coupons as $code => $qty) {
array_push($panierCoupons, ['cp_code' => $code, 'qty' => $qty]); array_push($panierCoupons, ['cp_code' => $code, 'qty' => $qty]);
} }
@ -306,7 +306,7 @@ class PanierController extends Controller
if (isset($request->panier) && $request->panier != "") { if (isset($request->panier) && $request->panier != "") {
$panier = $request->panier; $panier = $request->panier;
$panierTab = explode(",", $panier); $panierTab = explode(",", $panier);
$coupons = []; $coupons = array();
foreach ($panierTab as $panier) { foreach ($panierTab as $panier) {
$pos = strpos($panier, ")"); $pos = strpos($panier, ")");
if ($pos === false) { if ($pos === false) {
@ -333,7 +333,7 @@ class PanierController extends Controller
// ---- Préparation message de log avec coupons // ---- Préparation message de log avec coupons
if (isset($coupons)) { if (isset($coupons)) {
$panierCoupons = []; $panierCoupons = array();
foreach ($coupons as $code => $qty) { foreach ($coupons as $code => $qty) {
array_push($panierCoupons, ['cp_code' => $code, 'qty' => $qty]); array_push($panierCoupons, ['cp_code' => $code, 'qty' => $qty]);
} }

View file

@ -30,7 +30,13 @@ class BasketController extends Controller
{ {
// Validate required parameters // Validate required parameters
$requiredParams = ['customer_hashcode', 'refcamp', 'refsite', 'panier']; $requiredParams = ['customer_hashcode', 'refcamp', 'refsite', 'panier'];
$error = array_any($requiredParams, fn($param) => empty($request->{$param})); $error = false;
foreach ($requiredParams as $param) {
if (empty($request->{$param})) {
$error = true;
break;
}
}
if ($error) { if ($error) {
$this->writeLogErrorWrongRequestParameters( $this->writeLogErrorWrongRequestParameters(

View file

@ -12,7 +12,7 @@ use App\Models\Customers;
use App\Traits\CouponTrait; use App\Traits\CouponTrait;
use App\Traits\GenerateBR; use App\Traits\GenerateBR;
use PDF; use PDF;
use LDC\LDCCRM\CrmApiV4; use LDC\LDCCRM\CrmApiV2;
class CouponsController extends Controller class CouponsController extends Controller
{ {
@ -39,14 +39,14 @@ class CouponsController extends Controller
return new StatusResource(['status' => 'KO', 'code' => 422, 'message' => 'Coupons not found.']); return new StatusResource(['status' => 'KO', 'code' => 422, 'message' => 'Coupons not found.']);
} }
$crm = new CrmApiV4(config('services.crm.endpoint'), $campagne->site->crm_token, $campagne->site->crm_password); $crm = new CrmApiV2(config('services.crm.endpoint'), $campagne->site->crm_token, $campagne->site->crm_password);
try { try {
/** /**
* @var \LDC\LDCCRM\Models\Customer * @var \LDC\LDCCRM\Models\Customer
*/ */
$crmInfos = $crm->getCustomer($customer->hashcode); $crmInfos = $crm->getCustomer($customer->hashcode);
} catch (\Exception) { } catch (\Exception $e) {
// TODO : Update error message // TODO : Update error message
return new StatusResource(['status' => 'KO', 'code' => 422, 'message' => 'Customer not found.']); return new StatusResource(['status' => 'KO', 'code' => 422, 'message' => 'Customer not found.']);
} }
@ -60,7 +60,7 @@ class CouponsController extends Controller
$coupons = []; $coupons = [];
if ($campagne->camp_type->equals(CampaignTypes::mur())) { if ($campagne->camp_type->equals(CampaignTypes::mur())) {
// ---- POUR LES MURS // ---- POUR LES MURS
foreach ($couponsToPrint as $coupon_code) { foreach ($couponsToPrint as $key => $coupon_code) {
$cp = Coupon::where(['coupon_code' => $coupon_code])->first(); $cp = Coupon::where(['coupon_code' => $coupon_code])->first();
if (!$this->isUsed($cp, $campagne, $customer)) { if (!$this->isUsed($cp, $campagne, $customer)) {

View file

@ -17,7 +17,7 @@ class MaintenanceController extends Controller
DB::raw("COUNT(*) as count") DB::raw("COUNT(*) as count")
) )
->where('log_statut', 'NOK') ->where('log_statut', 'NOK')
->where('created_at', '>=', \Illuminate\Support\Facades\Date::now()->subMonths(5)->startOfMonth()) ->where('created_at', '>=', Carbon::now()->subMonths(5)->startOfMonth())
->groupBy('month') ->groupBy('month')
->orderBy('month', 'asc') ->orderBy('month', 'asc')
->get(); ->get();

View file

@ -36,7 +36,7 @@ class UserController extends Controller
$sites = Site::whereIn('site_id', $request->site)->get()->pluck('id')->toArray(); $sites = Site::whereIn('site_id', $request->site)->get()->pluck('id')->toArray();
$user->sites()->sync($sites); $user->sites()->sync($sites);
return to_route('bo.users.edit', $user); return redirect()->route('bo.users.edit', $user);
} }
public function edit(User $user) public function edit(User $user)
@ -56,16 +56,18 @@ class UserController extends Controller
$user->sites()->sync($sites); $user->sites()->sync($sites);
$marques = Auth::user()->sites; $marques = Auth::user()->sites;
$submarques = $marques->map(fn($marque) => $marque->only(['id', 'site_nom', 'site_id', 'site_logo'])); $submarques = $marques->map(function ($marque) {
return $marque->only(['id', 'site_nom', 'site_id', 'site_logo']);
});
session()->put('marques', $submarques); session()->put('marques', $submarques);
return to_route('bo.users.edit', $user); return redirect()->route('bo.users.edit', $user);
} }
public function destroy(DestroyUserRequest $request, User $user) public function destroy(DestroyUserRequest $request, User $user)
{ {
if ($user->delete()) { if ($user->delete()) {
return to_route('bo.users.index'); return redirect()->route('bo.users.index');
} else { } else {
session()->flash('delete_nok', 'Erreur lors de la suppression'); session()->flash('delete_nok', 'Erreur lors de la suppression');
return view('bo.user.index'); return view('bo.user.index');

View file

@ -17,6 +17,6 @@ class BrandChangeController extends Controller
// TODO : Revoir le passage du site // TODO : Revoir le passage du site
$site = \App\Models\Site::find($request->site_id); $site = \App\Models\Site::find($request->site_id);
session()->put('site', $site); session()->put('site', $site);
return back(); return redirect()->back();
} }
} }

View file

@ -92,7 +92,7 @@ class CampagneController extends Controller
// TODO : Revoir le passage du site id // TODO : Revoir le passage du site id
$siteId = session()->get('site')->id; $siteId = session()->get('site')->id;
$couponsNotLinked = Coupon::whereDoesntHave('campagnes', function (\Illuminate\Contracts\Database\Query\Builder $q) use ($campagne): void { $couponsNotLinked = Coupon::whereDoesntHave('campagnes', function ($q) use ($campagne) {
$q->where('campagne_id', $campagne->camp_id); $q->where('campagne_id', $campagne->camp_id);
})->where('coupon_siteId', $siteId)->where('coupon_published', 1)->get(); })->where('coupon_siteId', $siteId)->where('coupon_published', 1)->get();
@ -120,7 +120,7 @@ class CampagneController extends Controller
session()->flash('update_nok', __("Erreur lors de l'enregistrement")); session()->flash('update_nok', __("Erreur lors de l'enregistrement"));
} }
return to_route('campagne.edit', ['campagne' => $campagne]); return redirect()->route('campagne.edit', ['campagne' => $campagne]);
} }
/** /**
@ -169,7 +169,7 @@ class CampagneController extends Controller
$notification->fill(array_merge($request->validated(), ['notif_campId' => $campaign->camp_id])); $notification->fill(array_merge($request->validated(), ['notif_campId' => $campaign->camp_id]));
$notification->save(); $notification->save();
return back(); return redirect()->back();
} }
/** /**
@ -181,10 +181,10 @@ class CampagneController extends Controller
public function deleteNotification(RemoveNotifCampaign $request, Notification $notification) public function deleteNotification(RemoveNotifCampaign $request, Notification $notification)
{ {
if ($notification->delete()) { if ($notification->delete()) {
return back(); return redirect()->back();
} else { } else {
session()->flash('delete_nok', 'Erreur lors de la suppression'); session()->flash('delete_nok', 'Erreur lors de la suppression');
return back(); return redirect()->back();
} }
} }
@ -351,13 +351,13 @@ class CampagneController extends Controller
$type = "panier avec sélection"; $type = "panier avec sélection";
break; break;
} }
$data = [ $data = array (
'Site' => $site->site_nom, 'Site' => $site->site_nom,
'Ref campagne' => $campagne->camp_id, 'Ref campagne' => $campagne->camp_id,
'Nom campagne' => $campagne->camp_name, 'Nom campagne' => $campagne->camp_name,
"En ligne" => $enligne, "En ligne" => $enligne,
"Type" => $type, "Type" => $type,
]; );
$coupons = $campagne->coupons()->get(); $coupons = $campagne->coupons()->get();
@ -393,7 +393,7 @@ class CampagneController extends Controller
$dateFinValidite = date("d/m/Y", strtotime($coupon->coupon_maxdatevalidity)); $dateFinValidite = date("d/m/Y", strtotime($coupon->coupon_maxdatevalidity));
} }
$codeTraitement = [ $codeTraitement = array (
"Code traitement" => $coupon->coupon_code, "Code traitement" => $coupon->coupon_code,
"Nom" => $coupon->coupon_name, "Nom" => $coupon->coupon_name,
"Nb à diffuser" => $this->getFullQuantity($coupon), "Nb à diffuser" => $this->getFullQuantity($coupon),
@ -403,7 +403,7 @@ class CampagneController extends Controller
"En ligne" => $enligne, "En ligne" => $enligne,
"Date de fin de diffusion" => $dateFinDiffusion, "Date de fin de diffusion" => $dateFinDiffusion,
"Date de fin de validité" => $dateFinValidite, "Date de fin de validité" => $dateFinValidite,
]; );
$data['Coupons'][] = $codeTraitement; $data['Coupons'][] = $codeTraitement;
}//end foreach }//end foreach
}//end if }//end if

View file

@ -120,7 +120,7 @@ class CouponController extends Controller
} }
} }
return to_route('coupon.edit', ['coupon' => $coupon]); return redirect()->route('coupon.edit', ['coupon' => $coupon]);
} }
/** /**
@ -191,12 +191,12 @@ class CouponController extends Controller
} }
session()->flash('update_ok', 'Mise à jour du coupon réussie !'); session()->flash('update_ok', 'Mise à jour du coupon réussie !');
return to_route('coupon.edit', ['coupon' => $coupon]); return redirect()->route('coupon.edit', ['coupon' => $coupon]);
} else { } else {
return view('holder'); return view('holder');
} //end if } //end if
return to_route('coupon.edit', ['coupon' => $coupon]); return redirect()->route('coupon.edit', ['coupon' => $coupon]);
} }
/** /**
@ -210,7 +210,7 @@ class CouponController extends Controller
$coupon->coupon_published = 0; $coupon->coupon_published = 0;
$coupon->save(); $coupon->save();
if ($coupon->delete()) { if ($coupon->delete()) {
return to_route('coupon.index'); return redirect()->route('coupon.index');
} else { } else {
session()->flash('delete_nok', 'Erreur lors de la suppression'); session()->flash('delete_nok', 'Erreur lors de la suppression');
return back(); return back();

View file

@ -9,7 +9,7 @@ use App\Models\Basket;
use App\Traits\GenerateBR; use App\Traits\GenerateBR;
use PDF; use PDF;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use LDC\LDCCRM\CrmApiV4; use LDC\LDCCRM\CrmApiV2;
class BasketController extends Controller class BasketController extends Controller
{ {
@ -18,7 +18,9 @@ class BasketController extends Controller
// FIXME: Docblock // FIXME: Docblock
public function show(Request $request, Basket $basket) public function show(Request $request, Basket $basket)
{ {
$totalQuantity = $basket->contents->sum(fn($content) => $content->quantity - $content->printed); $totalQuantity = $basket->contents->sum(function ($content) {
return $content->quantity - $content->printed;
});
if (!$totalQuantity) { if (!$totalQuantity) {
return view('fo.basket.empty', compact('basket')); return view('fo.basket.empty', compact('basket'));
@ -32,14 +34,17 @@ class BasketController extends Controller
{ {
$campagne = $basket->campagne; $campagne = $basket->campagne;
$crm = new CrmApiV4(config('services.crm.endpoint'), $campagne->site->crm_token, $campagne->site->crm_password); // FIXME: Bump to CrmApiV4
$crm = new CrmApiV2(config('services.crm.endpoint'), $campagne->site->crm_token, $campagne->site->crm_password);
/** /**
* @var \LDC\LDCCRM\Models\Customer * @var \LDC\LDCCRM\Models\Customer
*/ */
$crmInfos = $crm->getCustomer($basket->customer->hashcode); $crmInfos = $crm->getCustomer($basket->customer->hashcode);
throw_if(is_null($crmInfos), \Exception::class, 'Customer not found.'); if (is_null($crmInfos)) {
throw new \Exception('Customer not found.');
}
$coupons = []; $coupons = [];
$currentDateTime = date('Y-m-d H:i:s'); $currentDateTime = date('Y-m-d H:i:s');
@ -78,7 +83,7 @@ class BasketController extends Controller
} }
if (empty($coupons)) { if (empty($coupons)) {
return to_route('fo.basket.show', $basket); return redirect()->route('fo.basket.show', $basket);
} }
// $coupons contains all printed coupons // $coupons contains all printed coupons

View file

@ -20,22 +20,28 @@ class PanierController extends Controller
{ {
// $panier = Panier::find($request->query('basketid')); // $panier = Panier::find($request->query('basketid'));
$panier = Panier::where(['panier_ref' => $request->basketid])->first(); $panier = Panier::where(['panier_ref' => $request->basketid])->first();
abort_unless($panier, 404); if (!$panier) {
abort(404);
}
session()->put('panier', $panier); session()->put('panier', $panier);
$panierCouponsCount = $this->getCountCouponsPanierPublished($panier); $panierCouponsCount = $this->getCountCouponsPanierPublished($panier);
$contact = Contact::where(['contact_id' => $panier->panier_contactId])->first(); $contact = Contact::where(['contact_id' => $panier->panier_contactId])->first();
abort_unless($contact, 404); if (!$contact) {
abort(404);
}
session()->put('contact', $contact); session()->put('contact', $contact);
$campagne = Campagne::where(['camp_id' => $panier->panier_campId, 'camp_published' => 1])->first(); $campagne = Campagne::where(['camp_id' => $panier->panier_campId, 'camp_published' => 1])->first();
abort_unless($campagne, 404); if (!$campagne) {
abort(404);
}
session()->put('campagne', $campagne); session()->put('campagne', $campagne);
if ($campagne->camp_type->equals(CampaignTypes::panier())) { if ($campagne->camp_type->equals(CampaignTypes::panier())) {
$coupons = $this->getCouponsPublished($campagne); $coupons = $this->getCouponsPublished($campagne);
} else { } else {
$panierContents = $this->getPanierContentPublished($panier); $panierContents = $this->getPanierContentPublished($panier);
$coupons = []; $coupons = array();
foreach ($panierContents as $panierContent) { foreach ($panierContents as $panierContent) {
$cp = Coupon::where(['coupon_id' => $panierContent->panier_content_couponId])->first(); $cp = Coupon::where(['coupon_id' => $panierContent->panier_content_couponId])->first();
$qty = $panierContent->panier_content_quantity; $qty = $panierContent->panier_content_quantity;
@ -57,7 +63,9 @@ class PanierController extends Controller
$coupons = session('coupons', []); $coupons = session('coupons', []);
abort_unless($request->session()->has('campagne'), 404); if (!$request->session()->has('campagne')) {
abort(404);
}
$campagne = $request->session()->get('campagne'); $campagne = $request->session()->get('campagne');

View file

@ -20,7 +20,7 @@ class RedirectController extends Controller
if (isset($request->basketid)) { if (isset($request->basketid)) {
return $panier->showTemplate($request); return $panier->showTemplate($request);
} else { } else {
return to_route('login'); return redirect()->route('login');
} }
} }
} }

View file

@ -66,7 +66,9 @@ class SiteController extends Controller
} }
// --- MAJ Selecteur marques // --- MAJ Selecteur marques
$marques = Auth::user()->sites; $marques = Auth::user()->sites;
$submarques = $marques->map(fn($marque) => $marque->only(['id', 'site_nom', 'site_id', 'site_logo'])); $submarques = $marques->map(function ($marque) {
return $marque->only(['id', 'site_nom', 'site_id', 'site_logo']);
});
session()->put('marques', $submarques); session()->put('marques', $submarques);
@ -99,7 +101,7 @@ class SiteController extends Controller
session()->flash('update_nok', 'Erreur lors de l\'enregistrement'); session()->flash('update_nok', 'Erreur lors de l\'enregistrement');
} }
return to_route('site.edit', ['site' => $site]); return redirect()->route('site.edit', ['site' => $site]);
} }
/** /**

View file

@ -50,7 +50,7 @@ class Kernel extends HttpKernel
* *
* @var array * @var array
*/ */
protected $middlewareAliases = [ protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class, 'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,

View file

@ -11,7 +11,6 @@ class CheckForMaintenanceMode extends Middleware
* *
* @var array * @var array
*/ */
protected $except = [ protected $except = [
]; ];
} }

View file

@ -11,7 +11,6 @@ class EncryptCookies extends Middleware
* *
* @var array * @var array
*/ */
protected $except = [ protected $except = [
]; ];
} }

View file

@ -18,7 +18,7 @@ class RedirectIfAuthenticated
public function handle($request, Closure $next, $guard = null) public function handle($request, Closure $next, $guard = null)
{ {
if (Auth::guard($guard)->check()) { if (Auth::guard($guard)->check()) {
return to_route('campagne.index'); return redirect()->route('campagne.index');
} }
return $next($request); return $next($request);

View file

@ -29,7 +29,9 @@ class SaveCurrentRoute
if (!$siteId) { if (!$siteId) {
$marques = Auth::user()->sites; $marques = Auth::user()->sites;
$submarques = $marques->map(fn($marque) => $marque->only(['id', 'site_nom', 'site_id', 'site_logo'])); $submarques = $marques->map(function ($marque) {
return $marque->only(['id', 'site_nom', 'site_id', 'site_logo']);
});
session()->put('marques', $submarques); session()->put('marques', $submarques);
} }

View file

@ -11,7 +11,6 @@ class TrimStrings extends Middleware
* *
* @var array * @var array
*/ */
protected $except = [ protected $except = [
'password', 'password',
'password_confirmation', 'password_confirmation',

View file

@ -3,7 +3,7 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Middleware\TrustProxies as Middleware; use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware class TrustProxies extends Middleware
{ {
@ -19,10 +19,5 @@ class TrustProxies extends Middleware
* *
* @var integer * @var integer
*/ */
protected $headers = protected $headers = Request::HEADER_X_FORWARDED_ALL;
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
} }

View file

@ -4,14 +4,13 @@ namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends \Illuminate\Foundation\Http\Middleware\PreventRequestForgery class VerifyCsrfToken extends Middleware
{ {
/** /**
* Indicates whether the XSRF-TOKEN cookie should be set on the response. * Indicates whether the XSRF-TOKEN cookie should be set on the response.
* *
* @var boolean * @var boolean
*/ */
protected $addHttpCookie = true; protected $addHttpCookie = true;
/** /**
@ -19,7 +18,6 @@ class VerifyCsrfToken extends \Illuminate\Foundation\Http\Middleware\PreventRequ
* *
* @var array * @var array
*/ */
protected $except = [ protected $except = [
'updatecontact', 'updatecontact',
'updatebasket', 'updatebasket',

View file

@ -30,7 +30,9 @@ class StoreNotifCampaign extends FormRequest
'notif_name' => 'min:5|required', 'notif_name' => 'min:5|required',
'notif_email' => [ 'notif_email' => [
'required', 'required',
Rule::unique('notification')->where(fn($query) => $query->where('notif_campId', $this->campaign->camp_id)), Rule::unique('notification')->where(function ($query) {
return $query->where('notif_campId', $this->campaign->camp_id);
}),
] ]
]; ];
} }

View file

@ -55,15 +55,21 @@ class StoreCoupons extends FormRequest
/** /**
* Configure the validator instance. * Configure the validator instance.
* *
* @param \Illuminate\Contracts\Validation\Validator $validator * @param \Illuminate\Validation\Validator $validator
* @return void * @return void
*/ */
public function withValidator($validator) public function withValidator($validator)
{ {
$validator->sometimes('coupon_gs1code', 'required|image|mimes:jpeg', fn($input) => isset($input->coupon_norme)); $validator->sometimes('coupon_gs1code', 'required|image|mimes:jpeg', function ($input) {
return isset($input->coupon_norme);
});
$validator->sometimes('coupon_limitquantity', 'integer|required', fn($input) => !is_null($input->coupon_enablelimitquantity)); $validator->sometimes('coupon_limitquantity', 'integer|required', function ($input) {
return !is_null($input->coupon_enablelimitquantity);
});
$validator->sometimes('coupon_limitperiod', 'integer|required', fn($input) => !is_null($input->coupon_enablelimitperiod)); $validator->sometimes('coupon_limitperiod', 'integer|required', function ($input) {
return !is_null($input->coupon_enablelimitperiod);
});
} }
} }

View file

@ -59,7 +59,7 @@ class UpdateCoupons extends FormRequest
/** /**
* Configure the validator instance. * Configure the validator instance.
* *
* @param \Illuminate\Contracts\Validation\Validator $validator * @param \Illuminate\Validation\Validator $validator
* @return void * @return void
*/ */
public function withValidator($validator) public function withValidator($validator)
@ -71,8 +71,12 @@ class UpdateCoupons extends FormRequest
return isset($input->coupon_norme); return isset($input->coupon_norme);
}); });
$validator->sometimes('coupon_limitquantity', 'integer|required', fn($input) => !is_null($input->coupon_enablelimitquantity)); $validator->sometimes('coupon_limitquantity', 'integer|required', function ($input) {
return !is_null($input->coupon_enablelimitquantity);
});
$validator->sometimes('coupon_limitperiod', 'integer|required', fn($input) => !is_null($input->coupon_enablelimitperiod)); $validator->sometimes('coupon_limitperiod', 'integer|required', function ($input) {
return !is_null($input->coupon_enablelimitperiod);
});
} }
} }

View file

@ -22,11 +22,19 @@ class PrintRequest extends FormRequest
{ {
$campagne = $this->basket->campagne; $campagne = $this->basket->campagne;
throw_unless($campagne->camp_type->equals(CampaignTypes::panier()), \Exception::class, 'Campaign is not basket.'); if (!$campagne->camp_type->equals(CampaignTypes::panier())) {
throw new \Exception('Campaign is not basket.');
}
throw_if($campagne->camp_published === 0, \Exception::class, 'Campaign is not published.'); if ($campagne->camp_published === 0) {
throw_if($campagne->site->crm_token === null, \Exception::class, 'CRM Token is missing.'); throw new \Exception('Campaign is not published.');
throw_if($campagne->site->crm_password === null, \Exception::class, 'CRM Password is missing.'); }
if ($campagne->site->crm_token === null) {
throw new \Exception('CRM Token is missing.');
}
if ($campagne->site->crm_password === null) {
throw new \Exception('CRM Password is missing.');
}
} }
/** /**

View file

@ -18,7 +18,7 @@ class CouponsResource extends JsonResource
'code' => $this->coupon_code, 'code' => $this->coupon_code,
'name' => $this->coupon_name, 'name' => $this->coupon_name,
'value' => $this->coupon_value, 'value' => $this->coupon_value,
'used' => $this->isUsed ?? false, 'used' => isset($this->isUsed) ? $this->isUsed : false,
'desktop_image_available' => $this->returnUrl($this->coupon_thumbnail1), 'desktop_image_available' => $this->returnUrl($this->coupon_thumbnail1),
'desktop_image_unavailable' => $this->returnUrl($this->coupon_thumbnail2), 'desktop_image_unavailable' => $this->returnUrl($this->coupon_thumbnail2),
'mobile_image_available' => $this->returnUrl($this->coupon_thumbnail3), 'mobile_image_available' => $this->returnUrl($this->coupon_thumbnail3),

View file

@ -37,10 +37,10 @@ class ArchiveStatsJob implements ShouldQueue
public function handle() public function handle()
{ {
try { try {
DB::transaction(function (): void { DB::transaction(function () {
Statistique::query() Statistique::query()
->where('date', '<', now()) ->where('date', '<', now())
->each(function ($stat): void { ->each(function ($stat) {
$archiveStat = new ArchiveStat(); $archiveStat = new ArchiveStat();
$archiveStat->quantity = $stat->stat_couponPrinted; $archiveStat->quantity = $stat->stat_couponPrinted;
$archiveStat->date = $stat->date; $archiveStat->date = $stat->date;

View file

@ -39,7 +39,7 @@ class CleanOldDatasJob implements ShouldQueue
{ {
try { try {
DB::transaction(function (): void { DB::transaction(function () {
// Delete old contacts. // Delete old contacts.
$deletedContact = Contact::query() $deletedContact = Contact::query()
->where('contact_updatedate', '<', now()->subYears(3)) ->where('contact_updatedate', '<', now()->subYears(3))

View file

@ -19,14 +19,20 @@ class DeleteCrmCustomerJob implements ShouldQueue
use Queueable; use Queueable;
use SerializesModels; use SerializesModels;
/**
* @var array $customer
*/
private $customer;
/** /**
* Create a new job instance. * Create a new job instance.
* *
* @param array $customer * @param array $customer
*/ */
public function __construct(private $customer) public function __construct($customer)
{ {
$this->onConnection('rabbitmq'); $this->onConnection('rabbitmq');
$this->customer = $customer;
} }
/** /**
@ -40,7 +46,7 @@ class DeleteCrmCustomerJob implements ShouldQueue
$email = $this->customer['email']; $email = $this->customer['email'];
try { try {
DB::transaction(function () use ($hashchode, $email): void { DB::transaction(function () use ($hashchode, $email) {
// For baskets and old walls. // For baskets and old walls.
$contact = Contact::query()->where('contact_ref', $hashchode)->first(); $contact = Contact::query()->where('contact_ref', $hashchode)->first();
if ($contact) { if ($contact) {
@ -82,7 +88,7 @@ class DeleteCrmCustomerJob implements ShouldQueue
$csvPath = \storage_path('/logs/crm.csv'); $csvPath = \storage_path('/logs/crm.csv');
if (!\file_exists($csvPath)) { if (!\file_exists($csvPath)) {
$logFile = fopen($csvPath, 'w'); $logFile = fopen($csvPath, 'w');
\fputcsv($logFile, ['date', 'hashcode', 'email', 'action'], ';', escape: '\\'); \fputcsv($logFile, ['date', 'hashcode', 'email', 'action'], ';');
\fclose($logFile); \fclose($logFile);
} }
@ -95,8 +101,7 @@ class DeleteCrmCustomerJob implements ShouldQueue
$this->customer['email'], $this->customer['email'],
$message $message
], ],
';', ';'
escape: '\\'
); );
\fclose($logFile); \fclose($logFile);
} }

View file

@ -170,12 +170,19 @@ class ExceptionsHelper
$argsCount = count($stack['args']); $argsCount = count($stack['args']);
for ($i = 0; $i < $argsCount; $i++) { for ($i = 0; $i < $argsCount; $i++) {
$type = \gettype($stack['args'][$i]); $type = \gettype($stack['args'][$i]);
match ($type) { switch ($type) {
'object' => $traceArgs .= sprintf('Object(%s)', $stack['args'][$i]::class), case 'object':
'array' => $traceArgs .= sprintf('Array(%d)', \count($stack['args'][$i])), $traceArgs .= sprintf('Object(%s)', \get_class($stack['args'][$i]));
'string' => $traceArgs .= sprintf('String(%d)', \strlen($stack['args'][$i])), break;
default => $traceArgs .= \gettype($stack['args'][$i]), case 'array':
}; $traceArgs .= sprintf('Array(%d)', \count($stack['args'][$i]));
break;
case 'string':
$traceArgs .= sprintf('String(%d)', \strlen($stack['args'][$i]));
break;
default:
$traceArgs .= \gettype($stack['args'][$i]);
}
$traceArgs .= ($i !== ($argsCount - 1) ? ',' : ''); $traceArgs .= ($i !== ($argsCount - 1) ? ',' : '');
} }
return $traceArgs; return $traceArgs;

View file

@ -11,6 +11,9 @@ class AlertBr extends Mailable
use Queueable; use Queueable;
use SerializesModels; use SerializesModels;
public $couponSeuil;
public $couponDiffusion;
public $subject; public $subject;
@ -20,8 +23,10 @@ class AlertBr extends Mailable
* *
* @return void * @return void
*/ */
public function __construct(public $couponSeuil, public $couponDiffusion, $sitename) public function __construct($couponSeuil, $couponDiffusion, $sitename)
{ {
$this->couponSeuil = $couponSeuil;
$this->couponDiffusion = $couponDiffusion;
$this->subject = 'Notification mes BR : ' . $sitename; $this->subject = 'Notification mes BR : ' . $sitename;
} }

View file

@ -11,6 +11,9 @@ class AlertBrAdmin extends Mailable
use Queueable; use Queueable;
use SerializesModels; use SerializesModels;
public $couponSeuil;
public $couponDiffusion;
public $subject; public $subject;
@ -20,8 +23,10 @@ class AlertBrAdmin extends Mailable
* *
* @return void * @return void
*/ */
public function __construct(public $couponSeuil, public $couponDiffusion) public function __construct($couponSeuil, $couponDiffusion)
{ {
$this->couponSeuil = $couponSeuil;
$this->couponDiffusion = $couponDiffusion;
$this->subject = 'Notification mes BR : Récapitulatif global'; $this->subject = 'Notification mes BR : Récapitulatif global';
} }

View file

@ -26,7 +26,6 @@ class ArchiveCampaign extends Model
* *
* @var array<int, string> * @var array<int, string>
*/ */
protected $fillable = [ protected $fillable = [
'name', 'name',
'campaign_id', 'campaign_id',
@ -40,7 +39,7 @@ class ArchiveCampaign extends Model
*/ */
protected static function booted(): void protected static function booted(): void
{ {
static::creating(function (self $model): void { static::creating(function (self $model) {
$model->assertFieldIsUnique('campaign_id', $model->campaign_id); $model->assertFieldIsUnique('campaign_id', $model->campaign_id);
$site = Site::query()->where('site_id', $model->archive_site_id)->firstOrFail(); $site = Site::query()->where('site_id', $model->archive_site_id)->firstOrFail();
$archiveSite = ArchiveSite::query()->firstOrCreate( $archiveSite = ArchiveSite::query()->firstOrCreate(
@ -53,10 +52,10 @@ class ArchiveCampaign extends Model
); );
$model->archiveSite()->associate($archiveSite); $model->archiveSite()->associate($archiveSite);
}); });
static::updating(function (): void { static::updating(function () {
throw new \RuntimeException('Updating an archived campaign is not authorized'); throw new \RuntimeException('Updating an archived campaign is not authorized');
}); });
static::deleting(function (): void { static::deleting(function () {
throw new \RuntimeException('Deleting an archived campaign is not authorized'); throw new \RuntimeException('Deleting an archived campaign is not authorized');
}); });
} }

View file

@ -24,7 +24,6 @@ class ArchiveCoupon extends Model
* *
* @var array<int, string> * @var array<int, string>
*/ */
protected $fillable = [ protected $fillable = [
'name', 'name',
'coupon_code', 'coupon_code',
@ -37,13 +36,13 @@ class ArchiveCoupon extends Model
*/ */
protected static function booted(): void protected static function booted(): void
{ {
static::creating(function (self $model): void { static::creating(function (self $model) {
$model->assertFieldIsUnique('coupon_code', $model->coupon_code); $model->assertFieldIsUnique('coupon_code', $model->coupon_code);
}); });
static::updating(function (): void { static::updating(function () {
throw new \RuntimeException('Updating an archived coupon is not authorized'); throw new \RuntimeException('Updating an archived coupon is not authorized');
}); });
static::deleting(function (): void { static::deleting(function () {
throw new \RuntimeException('Deleting an archived coupon is not authorized'); throw new \RuntimeException('Deleting an archived coupon is not authorized');
}); });
} }

View file

@ -24,7 +24,6 @@ class ArchiveSite extends Model
* *
* @var array<int, string> * @var array<int, string>
*/ */
protected $fillable = [ protected $fillable = [
'name', 'name',
'site_id', 'site_id',
@ -37,13 +36,13 @@ class ArchiveSite extends Model
*/ */
protected static function booted(): void protected static function booted(): void
{ {
static::creating(function (self $model): void { static::creating(function (self $model) {
$model->assertFieldIsUnique('site_id', $model->site_id); $model->assertFieldIsUnique('site_id', $model->site_id);
}); });
static::updating(function (self $model): void { static::updating(function (self $model) {
throw new \RuntimeException('Updating an archived site is not authorized'); throw new \RuntimeException('Updating an archived site is not authorized');
}); });
static::deleting(function (): void { static::deleting(function () {
throw new \RuntimeException('Deleting an archived site is not authorized'); throw new \RuntimeException('Deleting an archived site is not authorized');
}); });
} }

View file

@ -25,7 +25,6 @@ class ArchiveStat extends Model
* *
* @var array<int, string> * @var array<int, string>
*/ */
protected $fillable = [ protected $fillable = [
'date', 'date',
'quantity', 'quantity',
@ -38,7 +37,7 @@ class ArchiveStat extends Model
*/ */
protected static function booted(): void protected static function booted(): void
{ {
static::creating(function (self $model): void { static::creating(function (self $model) {
$campaign = Campagne::withTrashed()->where('camp_id', $model->archive_campaign_id)->firstOrFail(); $campaign = Campagne::withTrashed()->where('camp_id', $model->archive_campaign_id)->firstOrFail();
$archiveCampaign = ArchiveCampaign::query()->firstOrCreate( $archiveCampaign = ArchiveCampaign::query()->firstOrCreate(
[ [
@ -62,10 +61,10 @@ class ArchiveStat extends Model
); );
$model->archiveCoupon()->associate($archiveCoupon); $model->archiveCoupon()->associate($archiveCoupon);
}); });
static::updating(function (): void { static::updating(function () {
throw new \RuntimeException('Upating an archived stat is not authorized'); throw new \RuntimeException('Upating an archived stat is not authorized');
}); });
static::deleting(function (): void { static::deleting(function () {
throw new \RuntimeException('Deleting an archived stat is not authorized'); throw new \RuntimeException('Deleting an archived stat is not authorized');
}); });
} }

View file

@ -13,7 +13,6 @@ class Basket extends Model
{ {
use HasFactory; use HasFactory;
protected $fillable = [ protected $fillable = [
'campagne_id' 'campagne_id'
]; ];

View file

@ -18,7 +18,7 @@ class BasketContent extends Model
*/ */
protected static function booted() protected static function booted()
{ {
static::creating(function (self $model): void { static::creating(function (self $model) {
$model->printed = 0; $model->printed = 0;
}); });
} }

View file

@ -2,7 +2,6 @@
namespace App\Models; namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class Calendrier extends Model class Calendrier extends Model
@ -10,28 +9,23 @@ class Calendrier extends Model
/** /**
* @var string * @var string
*/ */
protected $table = 'calendrier'; protected $table = 'calendrier';
/** /**
* @var boolean * @var boolean
*/ */
public $timestamps = false; public $timestamps = false;
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'calendrier_id'; protected $primaryKey = 'calendrier_id';
protected $dates = ['calendrier_startdate', 'calendrier_enddate']; protected $dates = ['calendrier_startdate', 'calendrier_enddate'];
/** /**
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'calendrier_startdate', 'calendrier_startdate',
'calendrier_enddate' 'calendrier_enddate'
@ -43,7 +37,7 @@ class Calendrier extends Model
*/ */
public function coupon() public function coupon()
{ {
return $this->belongsTo(\App\Models\Coupon::class, 'calendrier_couponId'); return $this->belongsTo('App\Models\Coupon', 'calendrier_couponId');
} }
// * METHODS // * METHODS
@ -55,9 +49,6 @@ class Calendrier extends Model
*/ */
public function isPublished(): bool public function isPublished(): bool
{ {
return now()->betweenIncluded( return now()->betweenIncluded($this->calendrier_startdate, $this->calendrier_enddate->endOfDay());
Carbon::parse($this->calendrier_startdate),
Carbon::parse($this->calendrier_enddate)->endOfDay()
);
} }
} }

View file

@ -24,7 +24,6 @@ class Campagne extends Model
/** /**
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'camp_siteId', 'camp_siteId',
'camp_name', 'camp_name',
@ -51,19 +50,16 @@ class Campagne extends Model
/** /**
* @var string * @var string
*/ */
protected $table = 'campagne'; protected $table = 'campagne';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'camp_id'; protected $primaryKey = 'camp_id';
/** /**
* @var array * @var array
*/ */
protected $dates = ['camp_deleted_at']; protected $dates = ['camp_deleted_at'];
@ -74,7 +70,7 @@ class Campagne extends Model
*/ */
public function notifications() public function notifications()
{ {
return $this->hasMany(\App\Models\Notification::class, 'notif_campId', 'camp_id'); return $this->hasMany('App\Models\Notification', 'notif_campId', 'camp_id');
} }
/** /**
@ -83,7 +79,7 @@ class Campagne extends Model
*/ */
public function murs() public function murs()
{ {
return $this->hasMany(\App\Models\Mur::class, 'mur_campId', 'camp_id'); return $this->hasMany('App\Models\Mur', 'mur_campId', 'camp_id');
} }
/** /**
@ -92,7 +88,7 @@ class Campagne extends Model
*/ */
public function paniers() public function paniers()
{ {
return $this->hasMany(\App\Models\Panier::class, 'panier_campId', 'camp_id'); return $this->hasMany('App\Models\Panier', 'panier_campId', 'camp_id');
} }
/** /**
@ -101,7 +97,7 @@ class Campagne extends Model
*/ */
public function site() public function site()
{ {
return $this->belongsTo(\App\Models\Site::class, 'camp_siteId', 'site_id'); return $this->belongsTo('App\Models\Site', 'camp_siteId', 'site_id');
} }
/** /**
@ -109,7 +105,7 @@ class Campagne extends Model
*/ */
public function coupons() public function coupons()
{ {
return $this->belongsToMany(\App\Models\Coupon::class, 'campagne_coupon', 'campagne_id', 'coup_id'); return $this->belongsToMany('App\Models\Coupon', 'campagne_coupon', 'campagne_id', 'coup_id');
} }
/** /**

View file

@ -24,19 +24,16 @@ class Contact extends Model
/** /**
* @var string * @var string
*/ */
protected $table = 'contact'; protected $table = 'contact';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'contact_id'; protected $primaryKey = 'contact_id';
/** /**
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'contact_ref', 'contact_ref',
'contact_prenom', 'contact_prenom',
@ -53,7 +50,7 @@ class Contact extends Model
*/ */
public function murs() public function murs()
{ {
return $this->hasMany(\App\Models\Mur::class, 'mur_contactId', 'contact_id'); return $this->hasMany('App\Models\Mur', 'mur_contactId', 'contact_id');
} }
/** /**
@ -62,7 +59,7 @@ class Contact extends Model
*/ */
public function paniers() public function paniers()
{ {
return $this->hasMany(\App\Models\Panier::class, 'panier_contactId', 'contact_id'); return $this->hasMany('App\Models\Panier', 'panier_contactId', 'contact_id');
} }
/** /**
@ -71,63 +68,45 @@ class Contact extends Model
*/ */
public function site() public function site()
{ {
return $this->belongsTo(\App\Models\Site::class, 'contact_siteId'); return $this->belongsTo('App\Models\Site', 'contact_siteId');
} }
/** public function scopeSearchName($query, $name)
* @param \Illuminate\Database\Eloquent\Builder<static> $query
*/
protected function scopeSearchName($query, $name)
{ {
if ($name) { if ($name) {
$query->where('contact_nom', 'like', '%' . $name . '%'); $query->where('contact_nom', 'like', '%' . $name . '%');
} }
} }
/** public function scopeSearchFirstname($query, $firstname)
* @param \Illuminate\Database\Eloquent\Builder<static> $query
*/
protected function scopeSearchFirstname($query, $firstname)
{ {
if ($firstname) { if ($firstname) {
$query->where('contact_prenom', 'like', '%' . $firstname . '%'); $query->where('contact_prenom', 'like', '%' . $firstname . '%');
} }
} }
/** public function scopeSearchEmail($query, $email)
* @param \Illuminate\Database\Eloquent\Builder<static> $query
*/
protected function scopeSearchEmail($query, $email)
{ {
if ($email) { if ($email) {
$query->where('contact_email', 'like', '%' . $email . '%'); $query->where('contact_email', 'like', '%' . $email . '%');
} }
} }
/** public function scopeSearchVille($query, $ville)
* @param \Illuminate\Database\Eloquent\Builder<static> $query
*/
protected function scopeSearchVille($query, $ville)
{ {
if ($ville) { if ($ville) {
$query->where('contact_ville', 'like', '%' . $ville . '%'); $query->where('contact_ville', 'like', '%' . $ville . '%');
} }
} }
/** public function scopeSearchCp($query, $cp)
* @param \Illuminate\Database\Eloquent\Builder<static> $query
*/
protected function scopeSearchCp($query, $cp)
{ {
if ($cp) { if ($cp) {
$query->where('contact_cp', 'like', '%' . $cp . '%'); $query->where('contact_cp', 'like', '%' . $cp . '%');
} }
} }
/** public function scopeSearchCountry($query, $country)
* @param \Illuminate\Database\Eloquent\Builder<static> $query
*/
protected function scopeSearchCountry($query, $country)
{ {
if ($country) { if ($country) {
$query->where('contact_country', $country); $query->where('contact_country', $country);

View file

@ -30,19 +30,16 @@ class Coupon extends Model
/** /**
* @var string * @var string
*/ */
protected $table = 'coupon'; protected $table = 'coupon';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'coupon_id'; protected $primaryKey = 'coupon_id';
/** /**
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'coupon_code', 'coupon_code',
'coupon_norme', 'coupon_norme',
@ -80,7 +77,7 @@ class Coupon extends Model
*/ */
public function calendriers() public function calendriers()
{ {
return $this->hasMany(\App\Models\Calendrier::class, 'calendrier_couponId', 'coupon_id'); return $this->hasMany('App\Models\Calendrier', 'calendrier_couponId', 'coupon_id');
} }
/** /**
@ -89,7 +86,7 @@ class Coupon extends Model
*/ */
public function panierContents() public function panierContents()
{ {
return $this->hasMany(\App\Models\PanierContent::class, 'panier_content_couponId', 'coupon_id'); return $this->hasMany('App\Models\PanierContent', 'panier_content_couponId', 'coupon_id');
} }
/** /**
@ -98,7 +95,7 @@ class Coupon extends Model
*/ */
public function murs() public function murs()
{ {
return $this->hasMany(\App\Models\Mur::class, 'mur_couponId', 'coupon_id'); return $this->hasMany('App\Models\Mur', 'mur_couponId', 'coupon_id');
} }
/** /**
@ -107,7 +104,7 @@ class Coupon extends Model
*/ */
public function mouvements() public function mouvements()
{ {
return $this->hasMany(\App\Models\Mouvement::class, 'mouvement_couponId', 'coupon_id'); return $this->hasMany('App\Models\Mouvement', 'mouvement_couponId', 'coupon_id');
} }
/** /**
@ -116,7 +113,7 @@ class Coupon extends Model
*/ */
public function site() public function site()
{ {
return $this->belongsTo(\App\Models\Site::class, 'coupon_siteId'); return $this->belongsTo('App\Models\Site', 'coupon_siteId');
} }
/** /**
@ -124,7 +121,7 @@ class Coupon extends Model
*/ */
public function campagnes() public function campagnes()
{ {
return $this->belongsToMany(\App\Models\Campagne::class, 'campagne_coupon', 'coup_id', 'campagne_id'); return $this->belongsToMany('App\Models\Campagne', 'campagne_coupon', 'coup_id', 'campagne_id');
} }
/** /**

View file

@ -14,19 +14,16 @@ class Customers extends Model
/** /**
* @var string $primaryKey * @var string $primaryKey
*/ */
protected $primaryKey = 'hashcode'; protected $primaryKey = 'hashcode';
/** /**
* @var string $keyType * @var string $keyType
*/ */
protected $keyType = 'string'; protected $keyType = 'string';
/** /**
* @var array $fillable * @var array $fillable
*/ */
protected $fillable = ['hashcode', 'email', 'country']; protected $fillable = ['hashcode', 'email', 'country'];
/** /**
@ -36,12 +33,12 @@ class Customers extends Model
*/ */
protected static function booted() protected static function booted()
{ {
static::creating(function ($customer): void { static::creating(function ($customer) {
$customer->country = new Customers()->getIsoCountry($customer->country); $customer->country = (new Customers())->getIsoCountry($customer->country);
}); });
static::updating(function ($customer): void { static::updating(function ($customer) {
$customer->country = new Customers()->getIsoCountry($customer->country); $customer->country = (new Customers())->getIsoCountry($customer->country);
}); });
} }
@ -55,11 +52,16 @@ class Customers extends Model
private function getIsoCountry($country) private function getIsoCountry($country)
{ {
$country = trim(ucfirst(strtolower($country))); $country = trim(ucfirst(strtolower($country)));
$country = match ($country) { switch ($country) {
'Belgique' => 56, case 'Belgique':
'Luxembourg' => 442, $country = 56;
default => 250, break;
}; case 'Luxembourg':
$country = 442;
break;
default:
$country = 250;
}
return $country; return $country;
} }

View file

@ -6,19 +6,16 @@ use Illuminate\Database\Eloquent\Model;
class Log extends Model class Log extends Model
{ {
public $timestamps = false; public $timestamps = false;
/** /**
* @var string * @var string
*/ */
protected $table = 'logs'; protected $table = 'logs';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'id'; protected $primaryKey = 'id';
/** /**
* @var string * @var string
@ -28,7 +25,6 @@ class Log extends Model
/** /**
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'log_action', 'log_action',
'log_refsite', 'log_refsite',

View file

@ -9,28 +9,23 @@ class Mouvement extends Model
/** /**
* @var string * @var string
*/ */
protected $table = 'mouvement'; protected $table = 'mouvement';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'mouvement_id'; protected $primaryKey = 'mouvement_id';
/** /**
* @var boolean * @var boolean
*/ */
public $timestamps = false; public $timestamps = false;
protected $dates = ['mouvement_created_at']; protected $dates = ['mouvement_created_at'];
/** /**
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'mouvement_nombre', 'mouvement_nombre',
'mouvement_created_at' 'mouvement_created_at'
@ -42,6 +37,6 @@ class Mouvement extends Model
*/ */
public function coupon() public function coupon()
{ {
return $this->belongsTo(\App\Models\Coupon::class, 'mouvement_couponId'); return $this->belongsTo('App\Models\Coupon', 'mouvement_couponId');
} }
} }

View file

@ -9,19 +9,16 @@ class Mur extends Model
/** /**
* @var string * @var string
*/ */
protected $table = 'mur'; protected $table = 'mur';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'mur_id'; protected $primaryKey = 'mur_id';
/** /**
* @var boolean * @var boolean
*/ */
public $timestamps = false; public $timestamps = false;
/** /**
@ -30,7 +27,7 @@ class Mur extends Model
*/ */
public function campagne() public function campagne()
{ {
return $this->belongsTo(\App\Models\Campagne::class, 'mur_campId'); return $this->belongsTo('App\Models\Campagne', 'mur_campId');
} }
/** /**
@ -39,7 +36,7 @@ class Mur extends Model
*/ */
public function contact() public function contact()
{ {
return $this->belongsTo(\App\Models\Contact::class, 'mur_contactId'); return $this->belongsTo('App\Models\Contact', 'mur_contactId');
} }
/** /**
@ -48,6 +45,6 @@ class Mur extends Model
*/ */
public function coupon() public function coupon()
{ {
return $this->belongsTo(\App\Models\Coupon::class, 'mur_couponId'); return $this->belongsTo('App\Models\Coupon', 'mur_couponId');
} }
} }

View file

@ -9,22 +9,18 @@ class Notification extends Model
/** /**
* @var string * @var string
*/ */
protected $table = 'notification'; protected $table = 'notification';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'notif_id'; protected $primaryKey = 'notif_id';
/** /**
* @var boolean * @var boolean
*/ */
public $timestamps = false; public $timestamps = false;
protected $fillable = ['notif_name', 'notif_email', 'notif_campId']; protected $fillable = ['notif_name', 'notif_email', 'notif_campId'];
/** /**
@ -33,6 +29,6 @@ class Notification extends Model
*/ */
public function campagne() public function campagne()
{ {
return $this->belongsTo(\App\Models\Campagne::class, 'notif_campId'); return $this->belongsTo('App\Models\Campagne', 'notif_campId');
} }
} }

View file

@ -8,23 +8,20 @@ use Illuminate\Database\Eloquent\Model;
class Panier extends Model class Panier extends Model
{ {
use HasFactory; use HasFactory;
/** /**
* @var string * @var string
*/ */
protected $table = 'panier'; protected $table = 'panier';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'panier_id'; protected $primaryKey = 'panier_id';
/** /**
* @var boolean * @var boolean
*/ */
public $timestamps = false; public $timestamps = false;
// protected $with = ['panierContents']; // protected $with = ['panierContents'];
@ -34,7 +31,7 @@ class Panier extends Model
*/ */
public function panierContents() public function panierContents()
{ {
return $this->hasMany(\App\Models\PanierContent::class, 'panier_content_panierId', 'panier_id'); return $this->hasMany('App\Models\PanierContent', 'panier_content_panierId', 'panier_id');
} }
/** /**
@ -43,7 +40,7 @@ class Panier extends Model
*/ */
public function campagne() public function campagne()
{ {
return $this->belongsTo(\App\Models\Campagne::class, 'panier_campId'); return $this->belongsTo('App\Models\Campagne', 'panier_campId');
} }
/** /**
@ -52,6 +49,6 @@ class Panier extends Model
*/ */
public function contact() public function contact()
{ {
return $this->belongsTo(\App\Models\Contact::class, 'panier_contactId'); return $this->belongsTo('App\Models\Contact', 'panier_contactId');
} }
} }

View file

@ -9,19 +9,16 @@ class PanierContent extends Model
/** /**
* @var string * @var string
*/ */
protected $table = 'panier_content'; protected $table = 'panier_content';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'panier_content_id'; protected $primaryKey = 'panier_content_id';
/** /**
* @var boolean * @var boolean
*/ */
public $timestamps = false; public $timestamps = false;
/** /**
@ -30,7 +27,7 @@ class PanierContent extends Model
*/ */
public function panier() public function panier()
{ {
return $this->belongsTo(\App\Models\Panier::class, 'panier_content_panierId', 'panier_id'); return $this->belongsTo('App\Models\Panier', 'panier_content_panierId', 'panier_id');
} }
/** /**
@ -39,13 +36,12 @@ class PanierContent extends Model
*/ */
public function coupon() public function coupon()
{ {
return $this->belongsTo(\App\Models\Coupon::class, 'panier_content_couponId'); return $this->belongsTo('App\Models\Coupon', 'panier_content_couponId');
} }
/** /**
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'panier_content_panierId', 'panier_content_panierId',
'panier_content_couponId', 'panier_content_couponId',

View file

@ -12,31 +12,26 @@ class Site extends Model
/** /**
* @var string * @var string
*/ */
protected $table = 'site'; protected $table = 'site';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'id'; protected $primaryKey = 'id';
/** /**
* @var string * @var string
*/ */
protected $keyType = 'string'; protected $keyType = 'string';
/** /**
* @var boolean * @var boolean
*/ */
public $timestamps = false; public $timestamps = false;
/** /**
* @var array * @var array
*/ */
protected $fillable = ['site_nom', 'site_logo', 'site_contact', 'site_rcs', 'site_libelle']; protected $fillable = ['site_nom', 'site_logo', 'site_contact', 'site_rcs', 'site_libelle'];
/** /**
@ -45,7 +40,7 @@ class Site extends Model
*/ */
public function campagnes() public function campagnes()
{ {
return $this->hasMany(\App\Models\Campagne::class, 'camp_siteId', 'site_id'); return $this->hasMany('App\Models\Campagne', 'camp_siteId', 'site_id');
} }
/** /**
@ -54,7 +49,7 @@ class Site extends Model
*/ */
public function contacts() public function contacts()
{ {
return $this->hasMany(\App\Models\Contact::class, 'contact_siteId', 'site_id'); return $this->hasMany('App\Models\Contact', 'contact_siteId', 'site_id');
} }
/** /**
@ -62,7 +57,7 @@ class Site extends Model
*/ */
public function users() public function users()
{ {
return $this->belongsToMany(\App\Models\User::class, 'site_user', 'site_id', 'user_id'); return $this->belongsToMany('App\Models\User', 'site_user', 'site_id', 'user_id');
} }
/** /**
@ -71,13 +66,13 @@ class Site extends Model
*/ */
public function coupons() public function coupons()
{ {
return $this->hasMany(\App\Models\Coupon::class, 'coupon_siteId', 'id'); return $this->hasMany('App\Models\Coupon', 'coupon_siteId', 'id');
} }
/** /**
* @return string * @return string
*/ */
public function __toString(): string public function __toString()
{ {
return $this->site_id . " : " . $this->site_nom; return $this->site_id . " : " . $this->site_nom;
} }

View file

@ -6,19 +6,16 @@ use Illuminate\Database\Eloquent\Model;
class Statistique extends Model class Statistique extends Model
{ {
public $timestamps = false; public $timestamps = false;
/** /**
* @var string * @var string
*/ */
protected $table = 'statistiques'; protected $table = 'statistiques';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'id'; protected $primaryKey = 'id';
/** /**
* @var string * @var string
@ -28,7 +25,6 @@ class Statistique extends Model
/** /**
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'stat_campId', 'stat_campId',
'stat_couponId', 'stat_couponId',
@ -39,7 +35,6 @@ class Statistique extends Model
/** /**
* @var array * @var array
*/ */
protected $casts = [ protected $casts = [
'date' => 'date' 'date' => 'date'
]; ];
@ -51,7 +46,7 @@ class Statistique extends Model
*/ */
protected static function booted(): void protected static function booted(): void
{ {
static::creating(function (self $model): void { static::creating(function (self $model) {
$model->date = now()->toDateString(); $model->date = now()->toDateString();
}); });
} }

View file

@ -23,13 +23,11 @@ class User extends Authenticatable
/** /**
* @var string * @var string
*/ */
protected $table = 'users'; protected $table = 'users';
/** /**
* @var string * @var string
*/ */
protected $primaryKey = 'id'; protected $primaryKey = 'id';
/** /**
@ -37,7 +35,6 @@ class User extends Authenticatable
* *
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'name', 'email', 'password', 'roles', 'name', 'email', 'password', 'roles',
]; ];
@ -47,7 +44,6 @@ class User extends Authenticatable
* *
* @var array * @var array
*/ */
protected $hidden = [ protected $hidden = [
'password', 'remember_token', 'password', 'remember_token',
]; ];
@ -57,7 +53,7 @@ class User extends Authenticatable
*/ */
public function sites() public function sites()
{ {
return $this->belongsToMany(\App\Models\Site::class, 'site_user', 'user_id', 'site_id'); return $this->belongsToMany('App\Models\Site', 'site_user', 'user_id', 'site_id');
} }

View file

@ -30,7 +30,7 @@ class ResetPassword extends ResetPasswordNotification
*/ */
public function toMail($notifiable) public function toMail($notifiable)
{ {
return new MailMessage() return (new MailMessage())
->subject('MesBR - Réinitialisation du mot de passe') ->subject('MesBR - Réinitialisation du mot de passe')
->line('Vous recevez cet email car nous avons reçu une requête de réinitialisation de mot de passe pour votre compte.') ->line('Vous recevez cet email car nous avons reçu une requête de réinitialisation de mot de passe pour votre compte.')
->action('Réinitialiser votre mot de passe', url(config('app.url') . route('password.reset', $this->token, false))) ->action('Réinitialiser votre mot de passe', url(config('app.url') . route('password.reset', $this->token, false)))

View file

@ -11,7 +11,6 @@ class AuthServiceProvider extends ServiceProvider
* *
* @var array * @var array
*/ */
protected $policies = [ protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy', // 'App\Model' => 'App\Policies\ModelPolicy',
]; ];

View file

@ -13,7 +13,6 @@ class EventServiceProvider extends ServiceProvider
* *
* @var array * @var array
*/ */
protected $listen = [ protected $listen = [
Registered::class => [ Registered::class => [
SendEmailVerificationNotification::class, SendEmailVerificationNotification::class,

View file

@ -14,7 +14,6 @@ class RouteServiceProvider extends ServiceProvider
* *
* @var string * @var string
*/ */
protected $namespace = 'App\Http\Controllers'; protected $namespace = 'App\Http\Controllers';
/** /**

View file

@ -280,7 +280,7 @@ trait CouponTrait
// Paniers // Paniers
// TODO : Revoir la requete // TODO : Revoir la requete
$campagneId = $campagne->camp_id; $campagneId = $campagne->camp_id;
$countPrinted = PanierContent::where('panier_content_couponId', $coupon->coupon_id)->whereHas('panier', function ($query) use ($campagneId): void { $countPrinted = PanierContent::where('panier_content_couponId', $coupon->coupon_id)->whereHas('panier', function ($query) use ($campagneId) {
$query->where('panier_campId', $campagneId); $query->where('panier_campId', $campagneId);
})->sum('panier_content_printed'); })->sum('panier_content_printed');
} }
@ -299,7 +299,7 @@ trait CouponTrait
} else { } else {
// Paniers // Paniers
$campagneId = $campagne->camp_id; $campagneId = $campagne->camp_id;
$panierContents = PanierContent::where('panier_content_couponId', $coupon->coupon_id)->whereHas('panier', function ($query) use ($campagneId): void { $panierContents = PanierContent::where('panier_content_couponId', $coupon->coupon_id)->whereHas('panier', function ($query) use ($campagneId) {
$query->where('panier_campId', $campagneId); $query->where('panier_campId', $campagneId);
})->get(); })->get();
$panierContentCountPrinted = $panierContents->sum('panier_content_printed'); $panierContentCountPrinted = $panierContents->sum('panier_content_printed');
@ -323,11 +323,11 @@ trait CouponTrait
$countPrinted = $countPrinted + count($murs); $countPrinted = $countPrinted + count($murs);
} else { } else {
// Paniers // Paniers
$paniers = Panier::where(['panier_campId' => $campagne->camp_id])->where(function ($query) use ($startdate, $enddate): void { $paniers = Panier::where(['panier_campId' => $campagne->camp_id])->where(function ($query) use ($startdate, $enddate) {
$query->whereBetween('panier_createdate', [$startdate, $enddate]) $query->whereBetween('panier_createdate', [$startdate, $enddate])
->orWhereBetween('panier_updatedate', [$startdate, $enddate]); ->orWhereBetween('panier_updatedate', [$startdate, $enddate]);
})->get(); })->get();
foreach ($paniers as $panier) { foreach ($paniers as $key => $panier) {
$panierContentCount = $panier->panierContents->sum('panier_content_printed'); $panierContentCount = $panier->panierContents->sum('panier_content_printed');
$countPrinted = $countPrinted + $panierContentCount; $countPrinted = $countPrinted + $panierContentCount;
} }

View file

@ -32,7 +32,7 @@ trait GenerateBR
$product_image = public_path() . '/' . $coupon->coupon_decoration_image; $product_image = public_path() . '/' . $coupon->coupon_decoration_image;
// ---- Masque dans lequel l'image finale sera placée // ---- Masque dans lequel l'image finale sera placée
$mask = imagecreatefrompng($mask_img); $mask = imagecreatefrompng($mask_img);
[$maskWidth, $maskHeight] = getimagesize($mask_img); list($maskWidth, $maskHeight) = getimagesize($mask_img);
// ----- Mentions légales + RCS // ----- Mentions légales + RCS
if ($coupon->coupon_legal_mentions_splitted == 0) { if ($coupon->coupon_legal_mentions_splitted == 0) {
@ -184,10 +184,15 @@ trait GenerateBR
// ---- Créer le fichier final // ---- Créer le fichier final
imagepng($mask, storage_path('app/public/modelfiles/coupons') . "/" . $coupon->coupon_code . ".png", 9); imagepng($mask, storage_path('app/public/modelfiles/coupons') . "/" . $coupon->coupon_code . ".png", 9);
// ---- Libère la mémoire associée aux images manipulées
imagedestroy($logo);
imagedestroy($pdt);
imagedestroy($mask);
return "storage/modelfiles/coupons/" . $coupon->coupon_code . ".png"; return "storage/modelfiles/coupons/" . $coupon->coupon_code . ".png";
} }
public function imagettftextSp($image, $size, $angle, $x, $y, $color, $font, $text, $spacing = 0) function imagettftextSp($image, $size, $angle, $x, $y, $color, $font, $text, $spacing = 0)
{ {
if ($spacing == 0) { if ($spacing == 0) {
imagefttext($image, $size, $angle, $x, $y, $color, $font, $text); imagefttext($image, $size, $angle, $x, $y, $color, $font, $text);
@ -207,13 +212,13 @@ trait GenerateBR
public function imagettftextContour($image, $fontsize, $angle, $x, $y, $color, $font, $text, $color_contour, $contour_haut = 1, $contour_bas = 1, $contour_gauche = 1, $contour_droite = 1) function imagettftextContour($image, $fontsize, $angle, $x, $y, $color, $font, $text, $color_contour, $contour_haut = 1, $contour_bas = 1, $contour_gauche = 1, $contour_droite = 1)
{ {
$coords_x = []; $coords_x = array();
$coords_y = []; $coords_y = array();
for ($i_y = -$contour_haut; $i_y <= $contour_bas; $i_y++) { for ($i_y = -$contour_haut; $i_y <= $contour_bas; $i_y++) {
$y_temp = @array_fill(0, $contour_gauche + $contour_droite + 1, $i_y); $y_temp = @array_fill(0, $contour_gauche + $contour_droite + 1, $i_y);
$x_temp = []; $x_temp = array();
for ($i_x = -$contour_gauche; $i_x <= $contour_droite; $i_x++) { for ($i_x = -$contour_gauche; $i_x <= $contour_droite; $i_x++) {
$x_temp[] = $i_x; $x_temp[] = $i_x;
} }
@ -235,7 +240,7 @@ trait GenerateBR
// ---- Masque dans lequel l'image finale sera placée // ---- Masque dans lequel l'image finale sera placée
$mask = imagecreatefrompng($coupon->coupon_image); $mask = imagecreatefrompng($coupon->coupon_image);
[$maskWidth, $maskHeight] = getimagesize($coupon->coupon_image); list($maskWidth, $maskHeight) = getimagesize($coupon->coupon_image);
// ----- Mentions légales + RCS dépendant de l'user // ----- Mentions légales + RCS dépendant de l'user
@ -331,7 +336,7 @@ trait GenerateBR
if (($coupon->coupon_norme == 1 && strlen($contact->contact_cp) == 4) || $coupon->coupon_code == '5425003942648' || $coupon->coupon_code == '5425003941641') { if (($coupon->coupon_norme == 1 && strlen($contact->contact_cp) == 4) || $coupon->coupon_code == '5425003942648' || $coupon->coupon_code == '5425003941641') {
$codeBarre = imagecreatefromjpeg($coupon->coupon_gs1code); $codeBarre = imagecreatefromjpeg($coupon->coupon_gs1code);
imageresolution($codeBarre, 72); imageresolution($codeBarre, 72);
[$width, $height] = getimagesize($coupon->coupon_gs1code); list($width, $height) = getimagesize($coupon->coupon_gs1code);
$r = $width / $height; $r = $width / $height;
$w = 285; $w = 285;
$h = 150; $h = 150;
@ -365,6 +370,10 @@ trait GenerateBR
$contents = ob_get_contents(); $contents = ob_get_contents();
ob_end_clean(); ob_end_clean();
$dataUri = "data:image/jpeg;base64," . base64_encode($contents); $dataUri = "data:image/jpeg;base64," . base64_encode($contents);
// ---- Libère la mémoire associée aux images manipulées
imagedestroy($mask);
imagedestroy($ImageFond);
return $dataUri; return $dataUri;
} }
@ -376,7 +385,7 @@ trait GenerateBR
// Load base mask image // Load base mask image
$mask = imagecreatefrompng($coupon->coupon_image); $mask = imagecreatefrompng($coupon->coupon_image);
[$maskWidth, $maskHeight] = getimagesize($coupon->coupon_image); list($maskWidth, $maskHeight) = getimagesize($coupon->coupon_image);
// --- Draw Legal Mentions + RCS depending on the user country // --- Draw Legal Mentions + RCS depending on the user country
if ($coupon->coupon_legal_mentions_splitted == 1) { if ($coupon->coupon_legal_mentions_splitted == 1) {
@ -409,6 +418,8 @@ trait GenerateBR
} }
imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond));
imagedestroy($ImageMentionFond);
} }
// --- User inscription and city // --- User inscription and city
@ -444,6 +455,7 @@ trait GenerateBR
imagecolortransparent($ImageFond, $white); imagecolortransparent($ImageFond, $white);
imagecopy($mask, $ImageFond, 770, 40, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); imagecopy($mask, $ImageFond, 770, 40, 0, 0, imagesx($ImageFond), imagesy($ImageFond));
imagedestroy($ImageFond);
// --- Validity date inscription // --- Validity date inscription
$libelle = "Valable jusqu'au :"; $libelle = "Valable jusqu'au :";
@ -459,6 +471,7 @@ trait GenerateBR
imagecolortransparent($ImageFond, $white); imagecolortransparent($ImageFond, $white);
imagecopy($mask, $ImageFond, 780, 142, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); imagecopy($mask, $ImageFond, 780, 142, 0, 0, imagesx($ImageFond), imagesy($ImageFond));
imagedestroy($ImageFond);
// Save printed coupon // Save printed coupon
$printedCoupon = $this->savePrintedCoupon($campagne, $customer, $coupon); $printedCoupon = $this->savePrintedCoupon($campagne, $customer, $coupon);
@ -470,6 +483,7 @@ trait GenerateBR
$barcodeImage = imagecreatefromstring($base64); $barcodeImage = imagecreatefromstring($base64);
imagecopy($mask, $barcodeImage, 660, 355, 0, 0, imagesx($barcodeImage), imagesy($barcodeImage)); imagecopy($mask, $barcodeImage, 660, 355, 0, 0, imagesx($barcodeImage), imagesy($barcodeImage));
imagedestroy($barcodeImage);
// Text below right barcode // Text below right barcode
$ImageFond = imagecreate(380, 15); $ImageFond = imagecreate(380, 15);
@ -477,6 +491,7 @@ trait GenerateBR
$black = imagecolorallocate($ImageFond, 0, 0, 0); $black = imagecolorallocate($ImageFond, 0, 0, 0);
imagettftext($ImageFond, 11, 0, 0, 14, $black, $arial, $codeBarre); imagettftext($ImageFond, 11, 0, 0, 14, $black, $arial, $codeBarre);
imagecopy($mask, $ImageFond, 800, 385, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); imagecopy($mask, $ImageFond, 800, 385, 0, 0, imagesx($ImageFond), imagesy($ImageFond));
imagedestroy($ImageFond);
// --- Barcode treatment text // --- Barcode treatment text
if ($customer->country !== 250) { if ($customer->country !== 250) {
@ -495,12 +510,13 @@ trait GenerateBR
$black = imagecolorallocate($ImageFond, 0, 0, 0); $black = imagecolorallocate($ImageFond, 0, 0, 0);
imagettftext($ImageFond, 9, 0, 0, 10, $black, $arialbd, $textReduc); imagettftext($ImageFond, 9, 0, 0, 10, $black, $arialbd, $textReduc);
imagecopy($mask, $ImageFond, $copyPosition[0], $copyPosition[1], 0, 0, imagesx($ImageFond), imagesy($ImageFond)); imagecopy($mask, $ImageFond, $copyPosition[0], $copyPosition[1], 0, 0, imagesx($ImageFond), imagesy($ImageFond));
imagedestroy($ImageFond);
// --- Left barcode // --- Left barcode
if ($customer->country !== 250) { if ($customer->country !== 250) {
$codeBarreImg = imagecreatefromjpeg($coupon->coupon_gs1code); $codeBarreImg = imagecreatefromjpeg($coupon->coupon_gs1code);
imageresolution($codeBarreImg, 72); imageresolution($codeBarreImg, 72);
[$width, $height] = getimagesize($coupon->coupon_gs1code); list($width, $height) = getimagesize($coupon->coupon_gs1code);
$ratio = $width / $height; $ratio = $width / $height;
$maxWidth = 285; $maxWidth = 285;
$maxHeight = 150; $maxHeight = 150;
@ -516,18 +532,22 @@ trait GenerateBR
$resizedImage = imagecreatetruecolor($newWidth, $newHeight); $resizedImage = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($resizedImage, $codeBarreImg, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); imagecopyresampled($resizedImage, $codeBarreImg, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
imagecopy($mask, $resizedImage, 60, 250, 0, 0, $newWidth, $newHeight); imagecopy($mask, $resizedImage, 60, 250, 0, 0, $newWidth, $newHeight);
imagedestroy($codeBarreImg);
imagedestroy($resizedImage);
} else { } else {
$codeBarre = $coupon->coupon_code; $codeBarre = $coupon->coupon_code;
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); $generator = new \Picqer\Barcode\BarcodeGeneratorPNG();
$base64 = $generator->getBarcode($codeBarre, $generator::TYPE_CODE_128_A, 2, 46); $base64 = $generator->getBarcode($codeBarre, $generator::TYPE_CODE_128_A, 2, 46);
$barcodeImage = imagecreatefromstring($base64); $barcodeImage = imagecreatefromstring($base64);
imagecopy($mask, $barcodeImage, 10, 342, 0, 0, imagesx($barcodeImage), imagesy($barcodeImage)); imagecopy($mask, $barcodeImage, 10, 342, 0, 0, imagesx($barcodeImage), imagesy($barcodeImage));
imagedestroy($barcodeImage);
$ImageFond = imagecreate(380, 15); $ImageFond = imagecreate(380, 15);
$white = imagecolorallocate($ImageFond, 255, 255, 255); $white = imagecolorallocate($ImageFond, 255, 255, 255);
$black = imagecolorallocate($ImageFond, 0, 0, 0); $black = imagecolorallocate($ImageFond, 0, 0, 0);
imagettftext($ImageFond, 11, 0, 0, 14, $black, $arial, $codeBarre); imagettftext($ImageFond, 11, 0, 0, 14, $black, $arial, $codeBarre);
imagecopy($mask, $ImageFond, 52, 390, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); imagecopy($mask, $ImageFond, 52, 390, 0, 0, imagesx($ImageFond), imagesy($ImageFond));
imagedestroy($ImageFond);
} }
// Final output as base64 encoded JPEG // Final output as base64 encoded JPEG
@ -536,6 +556,8 @@ trait GenerateBR
$contents = ob_get_contents(); $contents = ob_get_contents();
ob_end_clean(); ob_end_clean();
imagedestroy($mask);
// Save stat. // Save stat.
$this->saveStat($campagne, $coupon); $this->saveStat($campagne, $coupon);

View file

@ -3,26 +3,33 @@
"description": "Webcoupon management system", "description": "Webcoupon management system",
"type": "project", "type": "project",
"require": { "require": {
"php": "^8.5", "php": "^7.3",
"ext-curl": "*", "ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"barryvdh/laravel-dompdf": "^3.1", "barryvdh/laravel-dompdf": "^0.9.0",
"doctrine/dbal": "^2.8",
"fideloper/proxy": "^4.0",
"kwaadpepper/enum": "^2.0", "kwaadpepper/enum": "^2.0",
"laravel/framework": "^13.0", "laravel/framework": "^8.0",
"laravel/tinker": "^3.0", "laravel/tinker": "^2.0",
"laravel/ui": "^4.0", "laravel/ui": "^3.0",
"ldc/ldccrmv4client": "^4.1", "laravelcollective/html": "6.*",
"picqer/php-barcode-generator": "^3.3", "ldc/ldccrmv2client": "^3.0.5",
"picqer/php-barcode-generator": "^0.3.0",
"sentry/sentry-laravel": "^4.13", "sentry/sentry-laravel": "^4.13",
"uwil/laravel-k8s": "^4.0" "uxweb/sweet-alert": "^2.0",
"vladimir-yuldashev/laravel-queue-rabbitmq": "^11.3"
}, },
"require-dev": { "require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0", "filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"laracasts/generators": "^1.1",
"mockery/mockery": "^1.0", "mockery/mockery": "^1.0",
"nunomaduro/collision": "^8.1", "nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^12.0", "phpunit/phpunit": "^9.0",
"slevomat/coding-standard": "^8.31", "slevomat/coding-standard": "^7.0",
"squizlabs/php_codesniffer": "^4.0" "squizlabs/php_codesniffer": "^3.3"
}, },
"repositories": [ "repositories": [
{ {
@ -70,19 +77,8 @@
], ],
"allow-plugins": { "allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true "dealerdirect/phpcodesniffer-composer-installer": true
},
"policy": {
"advisories": {
"ignore": {
"laravel/framework": {
"constraint": "^10.0",
"on-audit": false,
"reason": "Palier temporaire de migration vers une version Laravel maintenue. Ne pas deployer."
}
}
}
} }
}, },
"minimum-stability": "stable", "minimum-stability": "dev",
"prefer-stable": true "prefer-stable": true
} }

6454
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -152,6 +152,7 @@ return [
/* /*
* Package Service Providers... * Package Service Providers...
*/ */
Collective\Html\HtmlServiceProvider::class,
Barryvdh\DomPDF\ServiceProvider::class, Barryvdh\DomPDF\ServiceProvider::class,
/* /*
@ -210,8 +211,10 @@ return [
'URL' => Illuminate\Support\Facades\URL::class, 'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class, 'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class, 'View' => Illuminate\Support\Facades\View::class,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
'Debugbar' => Barryvdh\Debugbar\Facade::class, 'Debugbar' => Barryvdh\Debugbar\Facade::class,
'PDF' => Barryvdh\DomPDF\Facade\Pdf::class, 'PDF' => Barryvdh\DomPDF\Facade::class,
'CampaignTypes' => \App\Enums\CampaignTypes::class, 'CampaignTypes' => \App\Enums\CampaignTypes::class,
'Countries' => \App\Enums\Countries::class, 'Countries' => \App\Enums\Countries::class,
'UserRoles' => \App\Enums\UserRoles::class, 'UserRoles' => \App\Enums\UserRoles::class,

View file

@ -1,5 +1,7 @@
<?php <?php
use Illuminate\Database\DBAL\TimestampType;
return [ return [
/* /*
@ -122,5 +124,12 @@ return [
'database' => env('REDIS_CACHE_DB', 1), 'database' => env('REDIS_CACHE_DB', 1),
], ],
] ],
'dbal' => [
'types' => [
'timestamp' => TimestampType::class,
],
],
]; ];

View file

@ -1,6 +1,6 @@
<?php <?php
return [ return array(
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -14,7 +14,7 @@ return [
'show_warnings' => false, 'show_warnings' => false,
// Throw an Exception on warnings from dompdf // Throw an Exception on warnings from dompdf
'orientation' => 'portrait', 'orientation' => 'portrait',
'defines' => [ 'defines' => array(
/** /**
* The location of the DOMPDF font directory * The location of the DOMPDF font directory
* *
@ -243,7 +243,7 @@ return [
"DOMPDF_TEMP_DIR" => storage_path('logs/'), "DOMPDF_TEMP_DIR" => storage_path('logs/'),
// I need this // I need this
"DOMPDF_LOG_OUTPUT_FILE" => storage_path('logs/log.htm'), "DOMPDF_LOG_OUTPUT_FILE" => storage_path('logs/log.htm'),
], ),
]; );

View file

@ -57,5 +57,5 @@ return [
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#traces-sample-rate. // @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#traces-sample-rate.
'traces_sample_rate' => env('SENTRY_TRACES_SAMPLE_RATE') === null ? null : (float)env('SENTRY_TRACES_SAMPLE_RATE'), 'traces_sample_rate' => env('SENTRY_TRACES_SAMPLE_RATE') === null ? null : (float)env('SENTRY_TRACES_SAMPLE_RATE'),
'before_send' => \App\Lib\Helpers\ExceptionsHelper::sentryEventHandler(...), 'before_send' => [\App\Lib\Helpers\ExceptionsHelper::class, 'sentryEventHandler'],
]; ];

View file

@ -55,6 +55,11 @@ spec:
containers: containers:
- name: ${CI_PROJECT_PATH_SLUG}-container - name: ${CI_PROJECT_PATH_SLUG}-container
image: $IMAGE_TAG image: $IMAGE_TAG
command: ["/bin/sh", "-c"]
args:
- |
php artisan storage:link || true
exec apache2-foreground
envFrom: envFrom:
- configMapRef: - configMapRef:
name: ${CI_PROJECT_PATH_SLUG}-config-map name: ${CI_PROJECT_PATH_SLUG}-config-map
@ -85,9 +90,9 @@ spec:
imagePullSecrets: imagePullSecrets:
- name: docker-registry-credentials - name: docker-registry-credentials
securityContext: securityContext:
runAsUser: 82 runAsUser: 33
runAsGroup: 82 runAsGroup: 33
fsGroup: 82 fsGroup: 33
fsGroupChangePolicy: "OnRootMismatch" fsGroupChangePolicy: "OnRootMismatch"
volumes: volumes:
- name: storage - name: storage
@ -103,7 +108,7 @@ spec:
app: ${CI_PROJECT_PATH_SLUG}-app app: ${CI_PROJECT_PATH_SLUG}-app
ports: ports:
- port: 80 - port: 80
targetPort: 80 targetPort: 443
--- ---
apiVersion: traefik.io/v1alpha1 apiVersion: traefik.io/v1alpha1
kind: IngressRoute kind: IngressRoute
@ -168,8 +173,8 @@ spec:
persistentVolumeClaim: persistentVolumeClaim:
claimName: ${CI_PROJECT_PATH_SLUG}-pvc-storage claimName: ${CI_PROJECT_PATH_SLUG}-pvc-storage
securityContext: securityContext:
runAsUser: 82 runAsUser: 33
runAsGroup: 82 runAsGroup: 33
fsGroup: 82 fsGroup: 33
fsGroupChangePolicy: "OnRootMismatch" fsGroupChangePolicy: "OnRootMismatch"
restartPolicy: OnFailure restartPolicy: OnFailure

View file

@ -1,56 +0,0 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use RectorLaravel\Rector\Class_\CommandHiddenPropertyToHiddenAttributeRector;
use RectorLaravel\Rector\Class_\DescriptionPropertyToDescriptionAttributeRector;
use RectorLaravel\Rector\Class_\FillablePropertyToFillableAttributeRector;
use RectorLaravel\Rector\Class_\HiddenPropertyToHiddenAttributeRector;
use RectorLaravel\Rector\Class_\ModelCastsPropertyToCastsMethodRector;
use RectorLaravel\Rector\Class_\SignaturePropertyToSignatureAttributeRector;
use RectorLaravel\Rector\Class_\TablePropertyToTableAttributeRector;
use RectorLaravel\Rector\Class_\WithoutTimestampsPropertyToWithoutTimestampsAttributeRector;
use RectorLaravel\Rector\MethodCall\ValidationRuleArrayStringValueToArrayRector;
use RectorLaravel\Set\LaravelLevelSetList;
use RectorLaravel\Set\LaravelSetList;
return RectorConfig::configure()
->withAutoloadPaths([
__DIR__ . '/app',
__DIR__ . '/vendor/laravel/framework/src',
])
->withPaths([
__DIR__ . '/app',
__DIR__ . '/bootstrap',
__DIR__ . '/config',
__DIR__ . '/routes',
])
->withPhpSets(php85: true)
->withComposerBased(laravel: true)
->withSets([
LaravelLevelSetList::UP_TO_LARAVEL_130,
LaravelSetList::LARAVEL_ARRAYACCESS_TO_METHOD_CALL,
LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelSetList::LARAVEL_COLLECTION,
LaravelSetList::LARAVEL_IF_HELPERS,
LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES,
LaravelSetList::LARAVEL_TYPE_DECLARATIONS,
])
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0)
->withSkip([
// Disable Laravel notations.
CommandHiddenPropertyToHiddenAttributeRector::class,
DescriptionPropertyToDescriptionAttributeRector::class,
FillablePropertyToFillableAttributeRector::class,
HiddenPropertyToHiddenAttributeRector::class,
ModelCastsPropertyToCastsMethodRector::class,
SignaturePropertyToSignatureAttributeRector::class,
TablePropertyToTableAttributeRector::class,
WithoutTimestampsPropertyToWithoutTimestampsAttributeRector::class,
// Validation.
ValidationRuleArrayStringValueToArrayRector::class,
]);

View file

@ -101,8 +101,8 @@
<h4><i class="fas fa-plus-square addcalendar"></i> {{ __('Calendrier de diffusion') }}</h4> <h4><i class="fas fa-plus-square addcalendar"></i> {{ __('Calendrier de diffusion') }}</h4>
@foreach ($coupon->calendriers()->get() as $calendrier) @foreach ($coupon->calendriers()->get() as $calendrier)
<div class="form-field-calendar"> <div class="form-field-calendar">
<input type="date" name="startdate[]" value="{{ Carbon\Carbon::parse($calendrier->calendrier_startdate)->format('Y-m-d') }}"> <input type="date" name="startdate[]" value="{{ $calendrier->calendrier_startdate->format('Y-m-d') }}">
<input type="date" name="enddate[]" value="{{ Carbon\Carbon::parse($calendrier->calendrier_enddate)->format('Y-m-d') }}"> <input type="date" name="enddate[]" value="{{ $calendrier->calendrier_enddate->format('Y-m-d') }}">
<i class="fas fa-minus-square removecalendar"></i> <i class="fas fa-minus-square removecalendar"></i>
</div> </div>
@endforeach @endforeach
@ -117,7 +117,7 @@
</thead> </thead>
@foreach ($coupon->mouvements()->get() as $mouvement) @foreach ($coupon->mouvements()->get() as $mouvement)
<tr> <tr>
<th>{{ Carbon\Carbon::parse($mouvement->mouvement_created_at)->format('d/m/Y') }}</th> <th>{{ $mouvement->mouvement_created_at->format('d/m/Y') }}</th>
<th>{{ $mouvement->mouvement_nombre }}</th> <th>{{ $mouvement->mouvement_nombre }}</th>
<th></th> <th></th>
</tr> </tr>

View file

@ -0,0 +1,57 @@
@extends('layouts.main')
@section('content')
<h2><i class="fas fa-building"></i> Nouveau site</h2>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="form-wrapper">
{!! Form::open(['route' => 'site.store', 'enctype' => 'multipart/form-data']) !!}
<div class="form-split">
<div class="form-field">
{!! Form::label('site_id', 'Ref *') !!}
{!! Form::input('text', 'site_id', null, ['required']) !!}
</div>
<div class="form-field">
{!! Form::label('site_nom', 'Nom *') !!}
{!! Form::input('text', 'site_nom', null, ['required']) !!}
</div>
</div>
<div class="form-split">
<div class="form-field">
<div class="title">
{!! Form::label('site_logo', 'Logo *') !!}
<span>150x60px</span>
<span>Format: PNG</span>
</div>
{!! Form::file('site_logo', ['class' => 'input-file', 'required']) !!}
</div>
<div class="form-field">
{!! Form::label('site_contact', 'Contact *') !!}
{!! Form::email('site_contact', null, ['required']) !!}
</div>
</div>
<h4>Informations pour génération des BR :</h4>
<div class="form-split">
<div class="form-field">
{!! Form::label('site_libelle', 'Libellé du site *') !!}
{!! Form::input('text', 'site_libelle', null, ['required']) !!}
</div>
<div class="form-field">
{!! Form::label('site_rcs', 'RCS du site *') !!}
{!! Form::input('text', 'site_rcs', null, ['required']) !!}
</div>
</div>
<div class="form-field submit">
<span>Les champs avec un * sont obligatoires</span>
{!! Form::submit('Enregistrer') !!}
</div>
{!! Form::close() !!}
</div>
@endsection

View file

@ -0,0 +1,71 @@
@extends('layouts.main')
@section('content')
<h2><i class="fas fa-building"></i> Editer le site</h2>
<div class="form-wrapper">
<figure><img src="{{ asset($site->site_logo) }}" alt="{{ $site->site_nom }}"></figure>
{!! Form::model($site, ['route' => ['site.update', $site], 'enctype' => 'multipart/form-data']) !!}
@method('PUT')
<div class="form-split">
<div class="form-field">
{!! Form::label('site_id', 'Ref') !!}
{!! Form::input('text', 'site_id', null, ['required', 'readonly']) !!}
</div>
<div class="form-field">
{!! Form::label('site_nom', 'Nom') !!}
{!! Form::input('text', 'site_nom', null, ['required']) !!}
</div>
</div>
<div class="form-split">
<div class="form-field">
<div class="title">
{!! Form::label('site_logo', 'Logo') !!}
<span>150x60px</span>
</div>
{!! Form::file('site_logo', null, ['required']) !!}
{!! Form::input('hidden', 'site_logo_hidden', $site->site_logo) !!}
</div>
<div class="form-field">
{!! Form::label('site_contact', 'Contact') !!}
{!! Form::email('site_contact', null, ['required']) !!}
</div>
</div>
<h4>Informations pour génération des BR :</h4>
<div class="form-split">
<div class="form-field">
{!! Form::label('site_libelle', 'Libellé du site') !!}
{!! Form::input('text', 'site_libelle', null) !!}
</div>
<div class="form-field">
{!! Form::label('site_rcs', 'RCS du site') !!}
{!! Form::input('text', 'site_rcs', null) !!}
</div>
</div>
<div class="form-field submit">
{!! Form::submit('Mettre à jour') !!}
</div>
{!! Form::close() !!}
</div>
<div class="campagne-list">
<h2><i class="fa fa-folder"><i class="fas fa-ticket-alt"></i></i> Campagnes liées</h2>
<table>
<thead>
<tr>
<th>{{__('Ref') }}</th>
<th>{{__('Création') }}</th>
<th>{{__('Nom') }}</th>
</tr>
</thead>
<tbody>
@foreach($site->campagnes as $c)
<tr>
<td>{{ $c->camp_id }}</td>
<td>{{ $c->camp_name }}</td>
<td>{{ $c->camp_createdate }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

View file

@ -0,0 +1,25 @@
@extends('layouts.main')
@section('content')
<h2><i class="fas fa-building"></i> Sites <a href="{{ route('site.create') }}" class="add-button"><i class="fas fa-plus-square"></i> Ajouter</a></h2>
<div class="content-list">
<table>
<thead>
<tr>
<th>{{__('Ref') }}</th>
<th>{{__('Nom') }}</th>
<th>{{__('Contact') }}</th>
</tr>
</thead>
<tbody>
@foreach($sites as $s)
<tr>
<td><a href="{{ route('site.edit', $s) }}">{{ $s->site_id }}</a></td>
<td>{{ $s->site_nom }}</td>
<td>{{ $s->site_contact }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

View file

@ -15,7 +15,7 @@ use Illuminate\Support\Facades\Route;
Route::prefix('v1') Route::prefix('v1')
->name('api.v1.') ->name('api.v1.')
->group(function (): void { ->group(function () {
Route::get('/customer/mur', 'Api\v1\CustomerController@mur'); Route::get('/customer/mur', 'Api\v1\CustomerController@mur');
Route::get('/customer/basket', 'Api\v1\CustomerController@basket'); Route::get('/customer/basket', 'Api\v1\CustomerController@basket');
Route::get('/customer/basket/update', 'Api\v1\BasketController@updateBasket')->name('basket.update'); Route::get('/customer/basket/update', 'Api\v1\BasketController@updateBasket')->name('basket.update');

View file

@ -9,8 +9,10 @@ Auth::routes(['verify' => false, 'register' => false, 'reset' => false]);
Route::any('/', "RedirectController"); Route::any('/', "RedirectController");
Route::group(['prefix' => 'bo', 'middleware' => ['auth', 'saveroute']], function (): void { Route::group(['prefix' => 'bo', 'middleware' => ['auth', 'saveroute']], function () {
Route::get('/', fn() => redirect(route('campagne.index'))); Route::get('/', function () {
return redirect(route('campagne.index'));
});
Route::resource('site', 'SiteController')->except(['destroy', 'show']); Route::resource('site', 'SiteController')->except(['destroy', 'show']);
Route::resource('campagne', 'CampagneController')->except(['show']); Route::resource('campagne', 'CampagneController')->except(['show']);
@ -55,17 +57,17 @@ Route::post('/publish-coupons-ajax', 'AjaxController@publishCouponsAjax');
/** /**
* Clean * Clean
*/ */
Route::name('fo.')->group(function(): void { Route::name('fo.')->group(function() {
Route::name('basket.')->prefix('basket')->group(function (): void { Route::name('basket.')->prefix('basket')->group(function () {
Route::get('/{basket:uuid}', [BasketController::class, 'show'])->name('show'); Route::get('/{basket:uuid}', [BasketController::class, 'show'])->name('show');
Route::get('/{basket:uuid}/print', [BasketController::class, 'print'])->name('print'); Route::get('/{basket:uuid}/print', [BasketController::class, 'print'])->name('print');
}); });
}); });
Route::prefix('bo')->name('bo.')->middleware(['auth', 'saveroute'])->group(function(): void { Route::prefix('bo')->name('bo.')->middleware(['auth', 'saveroute'])->group(function() {
Route::name('maintenance.')->prefix('maintenance')->group(function (): void { Route::name('maintenance.')->prefix('maintenance')->group(function () {
Route::get('/', [MaintenanceController::class, 'index'])->name('index'); Route::get('/', [MaintenanceController::class, 'index'])->name('index');
}); });
Route::resource('users', \App\Http\Controllers\Bo\UserController::class); Route::resource('users', '\App\Http\Controllers\Bo\UserController');
}); });