Merge branch 'trunk'
This commit is contained in:
commit
b7c0e12429
116 changed files with 2368 additions and 1080 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -19,3 +19,4 @@ Homestead.yaml
|
|||
npm-debug.log
|
||||
yarn-error.log
|
||||
auth.json
|
||||
.vscode
|
||||
|
|
|
|||
|
|
@ -22,20 +22,10 @@ class CreateAdmin extends Command
|
|||
*/
|
||||
protected $description = 'creates an admin user upon password entry';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return integer
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,20 +21,10 @@ class ImportSalaries extends Command
|
|||
*/
|
||||
protected $description = 'Import Salaries, pour provision des clients';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return integer
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Command Name: LDC Web Status Checker
|
||||
* Description: Envoi des infos Serveur/Laravel vers LDC Web
|
||||
* Version: 1.0
|
||||
|
|
@ -28,16 +28,6 @@ class LDCWebStatusChecker extends Command
|
|||
*/
|
||||
protected $description = 'Envoi des infos Serveur/Laravel vers LDC Web';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -62,7 +52,7 @@ class LDCWebStatusChecker extends Command
|
|||
$data['robots'] = 'false';
|
||||
}
|
||||
|
||||
// Check logs
|
||||
// Check logs.
|
||||
$data['logs'] = 0;
|
||||
$patherror = storage_path('/logs');
|
||||
$files = glob($patherror . '/*.log');
|
||||
|
|
@ -74,7 +64,7 @@ class LDCWebStatusChecker extends Command
|
|||
|
||||
$data['code']['version'] = app()->version();
|
||||
|
||||
// Send by cURL
|
||||
// Send by cURL.
|
||||
$url = 'https://ldc-web.ldc.fr/api/status-checker';
|
||||
$ch = curl_init($url);
|
||||
$payload = ['token' => 'CE8S52Qq7stf5k8frF4T', 'datas' => json_encode($data)];
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class RefreshSiteMap extends Command
|
|||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return integer
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ class Kernel extends ConsoleKernel
|
|||
$schedule->command('sitemap:refresh')->dailyAt('16:13');
|
||||
$schedule->command('ldcweb:statuschecker')->everyFifteenMinutes();
|
||||
$schedule->job(JobsXmlIncoReader::class)->name('xml-inco-reader')->onOneServer()->dailyAt('15:00');
|
||||
// $schedule->job(new XmlIncoReader)->weeklyOn(1, '8:00');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ use Kwaadpepper\Enum\BaseEnum;
|
|||
*/
|
||||
final class InvoicingUnit extends BaseEnum
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -20,6 +25,11 @@ final class InvoicingUnit extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -29,6 +39,10 @@ final class InvoicingUnit extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ use Kwaadpepper\Enum\BaseEnum;
|
|||
*/
|
||||
final class OrderUnit extends BaseEnum
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -20,6 +25,11 @@ final class OrderUnit extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -29,6 +39,10 @@ final class OrderUnit extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
class PriceShowingMode extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -22,6 +27,11 @@ class PriceShowingMode extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ use Kwaadpepper\Enum\BaseEnum;
|
|||
*/
|
||||
final class SellUnit extends BaseEnum
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -20,6 +25,11 @@ final class SellUnit extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -29,6 +39,10 @@ final class SellUnit extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnum;
|
|||
*/
|
||||
final class SettingRegisterMode extends BaseEnum
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -18,6 +23,11 @@ final class SettingRegisterMode extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -26,6 +36,10 @@ final class SettingRegisterMode extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ use Kwaadpepper\Enum\BaseEnum;
|
|||
*/
|
||||
final class WeightUnit extends BaseEnum
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -20,6 +25,11 @@ final class WeightUnit extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -29,6 +39,12 @@ final class WeightUnit extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* conversion values
|
||||
* base kg()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function convert(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -38,6 +54,10 @@ final class WeightUnit extends BaseEnum
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace App\Exceptions;
|
|||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
|
|
@ -15,8 +14,7 @@ class Handler extends ExceptionHandler
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
];
|
||||
protected $dontReport = [];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
|
|
@ -37,6 +35,13 @@ class Handler extends ExceptionHandler
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle unauthenticated as exception
|
||||
*
|
||||
* @param mixed $request
|
||||
* @param AuthenticationException $exception
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function unauthenticated($request, AuthenticationException $exception)
|
||||
{
|
||||
if ($request->expectsJson()) {
|
||||
|
|
@ -51,47 +56,42 @@ class Handler extends ExceptionHandler
|
|||
$login = 'auth.login';
|
||||
break;
|
||||
}
|
||||
// cf. issue https://stackoverflow.com/questions/52417438/laravel-unauthenticated-redirect-issue-with-multiple-authentication
|
||||
// Session::forget('url.intented');
|
||||
// Cf. issue :
|
||||
// Https://stackoverflow.com/questions/52417438/laravel-unauthenticated-redirect-issue-with-multiple-authentication.
|
||||
// Session::forget('url.intented'); .
|
||||
return redirect()->guest(route($login));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Throwable $exception
|
||||
* @param \Throwable $e
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function report(Throwable $e)
|
||||
{
|
||||
if (get_class($e) == RedirectTo::class) {
|
||||
abort(redirect($e->url));
|
||||
}
|
||||
try {
|
||||
if (config('app.debug') === false) {
|
||||
if ($this->shouldntReport($e)) {
|
||||
return;
|
||||
}
|
||||
Mail::send([
|
||||
'html' => 'emails.exception',
|
||||
'text' => 'emails.exception-plain'
|
||||
], [
|
||||
'exception' => $e,
|
||||
'appName' => config('app.name')
|
||||
], function ($m) {
|
||||
$m->to(
|
||||
config('mail.contactsList.serviceweb'),
|
||||
sprintf('%s Exception Handler', config('app.name'))
|
||||
)->subject('Need help !, an error occured in your application, please check Logs ASAP');
|
||||
});
|
||||
|
||||
if (config('app.debug') === false) {
|
||||
if ($this->shouldntReport($e)) {
|
||||
return;
|
||||
}
|
||||
// phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
|
||||
} catch (RuntimeException $e) {
|
||||
// do nothing, mail send error, let laravel only handle this
|
||||
} finally {
|
||||
parent::report($e);
|
||||
}//end try
|
||||
Mail::send([
|
||||
'html' => 'emails.exception',
|
||||
'text' => 'emails.exception-plain'
|
||||
], [
|
||||
'exception' => $e,
|
||||
'appName' => config('app.name')
|
||||
], function ($m) {
|
||||
$m->to(
|
||||
config('mail.contactsList.serviceweb'),
|
||||
sprintf('%s Exception Handler', config('app.name'))
|
||||
)->subject('Need help !, an error occured in your application, please check Logs ASAP');
|
||||
});
|
||||
}
|
||||
|
||||
parent::report($e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,27 @@ use Illuminate\Support\Facades\Auth;
|
|||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display login form
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
return view('auth.login-bo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute login form
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
|
|
@ -37,8 +53,17 @@ class LoginController extends Controller
|
|||
return view('auth.login')->withErrors('Informations incorrectes.');
|
||||
}
|
||||
|
||||
/**
|
||||
* logout
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function logout(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
Auth::logout();
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,27 @@ use Illuminate\Support\Facades\Hash;
|
|||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display register form
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
return view('auth.register');
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute regioster form
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
*/
|
||||
public function register(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
|
|
@ -34,7 +50,7 @@ class RegisterController extends Controller
|
|||
'role' => 3
|
||||
]);
|
||||
|
||||
// Envoi mail activation
|
||||
// Envoi mail activation.
|
||||
return redirect()->route('auth.register')->with('success', 'Mail envoyé pour confirmation');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,17 @@ use Illuminate\Http\Request;
|
|||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display reset password form
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
return view('auth.reset-password');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ class BasketController extends Controller
|
|||
{
|
||||
/**
|
||||
* ajout de produit au panier
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function addToCart(Request $request)
|
||||
{
|
||||
|
|
@ -24,6 +28,10 @@ class BasketController extends Controller
|
|||
|
||||
/**
|
||||
* ajout de plusieurs produits au panier
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function addToCartLot(Request $request)
|
||||
{
|
||||
|
|
@ -39,6 +47,10 @@ class BasketController extends Controller
|
|||
|
||||
/**
|
||||
* suppression de produit du panier
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function removeFromCart(Request $request)
|
||||
{
|
||||
|
|
@ -51,6 +63,10 @@ class BasketController extends Controller
|
|||
|
||||
/**
|
||||
* vidage de panier
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function emptyCart(Request $request)
|
||||
{
|
||||
|
|
@ -62,6 +78,10 @@ class BasketController extends Controller
|
|||
|
||||
/**
|
||||
* récupération du panier
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCartRequest(Request $request)
|
||||
{
|
||||
|
|
@ -70,14 +90,19 @@ class BasketController extends Controller
|
|||
return $this->getCart($instance);
|
||||
}
|
||||
|
||||
|
||||
public function getCart($instance = "panier")
|
||||
/**
|
||||
* return cart data array
|
||||
*
|
||||
* @param string $instance
|
||||
* @return array
|
||||
*/
|
||||
public function getCart(string $instance = "panier")
|
||||
{
|
||||
Cart::instance($instance);
|
||||
$dbpanier = new Collection();
|
||||
foreach (Cart::content() as $row) {
|
||||
$product = $row->model;
|
||||
// $product->additionnalProductInfo = $product->additionnalProductInfo($product->product_type);
|
||||
|
||||
$product->calculatedPrices = $product->getCalcPrices();
|
||||
|
||||
$row->setTaxRate($product->tax->rate);
|
||||
|
|
@ -92,34 +117,34 @@ class BasketController extends Controller
|
|||
|
||||
$cartInfos = array(
|
||||
"totalTTC" => Cart::total(),
|
||||
// Total des taxes.
|
||||
'totalTVA' => Cart::tax(),
|
||||
// total des taxes
|
||||
// Total sans les taxes.
|
||||
'totalHT' => Cart::subtotal(),
|
||||
// total sans les taxes
|
||||
// Poids total des items.
|
||||
'totalweight' => Cart::weight(),
|
||||
// poids total des items
|
||||
// Total avant taxes et remises.
|
||||
'totalHTbefore' => Cart::priceTotal(),
|
||||
// total avant taxes et remises
|
||||
// Total des remises.
|
||||
'totaldiscount' => Cart::discount(),
|
||||
// total des remises
|
||||
// Nb de produits dans le cart.
|
||||
'countItems' => Cart::count(),
|
||||
// nb de produits dans le cart
|
||||
);
|
||||
|
||||
$cartInfosNoPrice = array(
|
||||
"totalTTC" => "-.--",
|
||||
// Total des taxes.
|
||||
'totalTVA' => "-.--",
|
||||
// total des taxes
|
||||
// Total sans les taxes.
|
||||
'totalHT' => "-.--",
|
||||
// total sans les taxes
|
||||
// Poids total des items.
|
||||
'totalweight' => Cart::weight(),
|
||||
// poids total des items
|
||||
// Total avant taxes et remises.
|
||||
'totalHTbefore' => "-.--",
|
||||
// total avant taxes et remises
|
||||
// Total des remises.
|
||||
'totaldiscount' => "-.--",
|
||||
// total des remises
|
||||
// Nb de produits dans le cart.
|
||||
'countItems' => Cart::count(),
|
||||
// nb de produits dans le cart
|
||||
);
|
||||
|
||||
$cartReturn = array($dbpanier,$cartInfosNoPrice);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,15 @@ use Illuminate\Http\Request;
|
|||
|
||||
class ContentController extends Controller
|
||||
{
|
||||
public function manage(Request $request, $key)
|
||||
/**
|
||||
* Manage content page
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $key
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
*/
|
||||
public function manage(Request $request, string $key)
|
||||
{
|
||||
$content = Content::where('key', $key)->first();
|
||||
|
||||
|
|
|
|||
|
|
@ -9,20 +9,35 @@ use Illuminate\Http\Request;
|
|||
|
||||
class CreneauxController extends Controller
|
||||
{
|
||||
public function settings(Request $request, $id)
|
||||
/**
|
||||
* Display creneaux settings form
|
||||
*
|
||||
* @param Request $request
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
*/
|
||||
public function settings(Request $request, int $id)
|
||||
{
|
||||
|
||||
// @phpcs:enable
|
||||
$magasin = Magasin::findOrFail($id);
|
||||
$timeslotSettings = $magasin->timeslotSettings;
|
||||
if ($timeslotSettings->count() === 0) {
|
||||
// Aucun settings pour ce magasin
|
||||
// Aucun settings pour ce magasin.
|
||||
$timeslotSettings = $this->makeCreneauxSettings($id);
|
||||
}
|
||||
|
||||
return view('bo.creneaux.settings', compact('timeslotSettings', 'magasin'));
|
||||
}
|
||||
|
||||
public function makeCreneauxSettings($id)
|
||||
/**
|
||||
* Retrieve creneaux settings
|
||||
*
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function makeCreneauxSettings(int $id)
|
||||
{
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$dayset = new TimeslotSetting();
|
||||
|
|
@ -33,7 +48,14 @@ class CreneauxController extends Controller
|
|||
return Magasin::findOrFail($id)->timeslotSettings;
|
||||
}
|
||||
|
||||
public function updateSettings(Request $request, $id)
|
||||
/**
|
||||
* save settings
|
||||
*
|
||||
* @param Request $request
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function updateSettings(Request $request, int $id)
|
||||
{
|
||||
$plage = $request->plage;
|
||||
$magasin_id = $id;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ use App\Http\Controllers\Controller;
|
|||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Dashboard Page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('bo.dashboard');
|
||||
|
|
|
|||
|
|
@ -8,17 +8,29 @@ use Illuminate\Http\Request;
|
|||
|
||||
class FaqController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$faq = Faq::all();
|
||||
return view('bo.faq.index', compact('faq'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update faq data.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function saveDatas(Request $request)
|
||||
{
|
||||
$faq = $request->faq;
|
||||
|
||||
for ($i = 0; $i < count($faq); $i++) {
|
||||
$looplimit = count($faq);
|
||||
for ($i = 0; $i < $looplimit; $i++) {
|
||||
$faqToInsert = !empty($faq[$i]["question"]) && !empty($faq[$i]["answer"]);
|
||||
if (isset($faq[$i]["id"]) && $faq[$i]["id"] !== null && $faqToInsert) {
|
||||
$f = Faq::findOrFail($faq[$i]["id"]);
|
||||
|
|
@ -27,7 +39,10 @@ class FaqController extends Controller
|
|||
$f->save();
|
||||
} else {
|
||||
if ($faqToInsert) {
|
||||
$c = Faq::updateOrCreate(['question' => $faq[$i]["question"], 'answer' => $faq[$i]["answer"]]);
|
||||
$c = Faq::updateOrCreate([
|
||||
'question' => $faq[$i]["question"],
|
||||
'answer' => $faq[$i]["answer"]
|
||||
]);
|
||||
$faq[$i]["id"] = $c->id;
|
||||
} else {
|
||||
unset($faq[$i]);
|
||||
|
|
@ -39,6 +54,12 @@ class FaqController extends Controller
|
|||
return $faq;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$faq = Faq::findOrFail($request->id);
|
||||
|
|
|
|||
|
|
@ -49,23 +49,13 @@ class MagasinsController extends Controller
|
|||
return redirect()->route('bo.magasins.edit', $shop->id)->with('success', 'Nouveau Magasin enregistré !');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(int $id)
|
||||
{
|
||||
$magasin = Magasin::findOrFail($id);
|
||||
$exceptionsCollecte = $magasin->collecteExceptions()->orderBy('date')->get();
|
||||
|
|
@ -79,7 +69,7 @@ class MagasinsController extends Controller
|
|||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
|
|
@ -99,16 +89,16 @@ class MagasinsController extends Controller
|
|||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$shop = Magasin::findOrFail($id);
|
||||
|
||||
$count = Magasin::count();
|
||||
|
||||
if ($count === 1) {
|
||||
return redirect()->back()->withErrors("Suppression impossible : Vous devez conserver au moins 1 point de retrait.");
|
||||
return redirect()->back()
|
||||
->withErrors("Suppression impossible : Vous devez conserver au moins 1 point de retrait.");
|
||||
}
|
||||
// @todo : controller les crenaux settings liés
|
||||
$shop->delete();
|
||||
return redirect()->route('bo.magasins.index');
|
||||
}
|
||||
|
|
@ -116,8 +106,12 @@ class MagasinsController extends Controller
|
|||
/**
|
||||
* bo
|
||||
* ajx : affichage d'infos sur un magasin
|
||||
*
|
||||
* @param integer $id
|
||||
* @param string|null $mode
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function getMagasinInfo($id, $mode = null)
|
||||
public function getMagasinInfo(int $id, string $mode = null)
|
||||
{
|
||||
$magasin = Magasin::findOrFail($id);
|
||||
if (!is_null($mode)) {
|
||||
|
|
@ -132,13 +126,24 @@ class MagasinsController extends Controller
|
|||
return view('bo.magasins.info-popup', compact('magasin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Save collect exceptions
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function saveExceptions(Request $request)
|
||||
{
|
||||
$collecteException = $request->collecte_exception;
|
||||
|
||||
for ($i = 0; $i < count($collecteException); $i++) {
|
||||
$looplimit = count($collecteException);
|
||||
for ($i = 0; $i < $looplimit; $i++) {
|
||||
$collecteExceptionToInsert = !empty($collecteException[$i]["date"]);
|
||||
if (isset($collecteException[$i]["id"]) && $collecteException[$i]["id"] !== null && $collecteExceptionToInsert) {
|
||||
if (
|
||||
isset($collecteException[$i]["id"]) &&
|
||||
$collecteException[$i]["id"] !== null &&
|
||||
$collecteExceptionToInsert
|
||||
) {
|
||||
$ce = CollecteException::findOrFail($collecteException[$i]["id"]);
|
||||
$ce->date = $collecteException[$i]["date"];
|
||||
$ce->comment = $collecteException[$i]["comment"];
|
||||
|
|
@ -159,16 +164,20 @@ class MagasinsController extends Controller
|
|||
}
|
||||
}//end for
|
||||
|
||||
// remet dans l'ordre avant de renvoyer
|
||||
// $collecteException = CollecteException::where('magasin_id',)->orderBy('date')->get();
|
||||
// Remet dans l'ordre avant de renvoyer.
|
||||
$this->arraySortByColumn($collecteException, "date");
|
||||
return $collecteException;
|
||||
}
|
||||
|
||||
/**
|
||||
* helper function
|
||||
*
|
||||
* @param array $array
|
||||
* @param string $column
|
||||
* @param integer $direction
|
||||
* @return void
|
||||
*/
|
||||
public function arraySortByColumn(&$array, $column, $direction = SORT_ASC)
|
||||
public function arraySortByColumn(array &$array, string $column, int $direction = SORT_ASC)
|
||||
{
|
||||
$reference_array = array();
|
||||
|
||||
|
|
@ -179,6 +188,12 @@ class MagasinsController extends Controller
|
|||
array_multisort($reference_array, $direction, $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete collecte exception
|
||||
*
|
||||
* @param Request $request
|
||||
* @return string
|
||||
*/
|
||||
public function destroyExceptions(Request $request)
|
||||
{
|
||||
$collecteException = CollecteException::findOrFail($request->id);
|
||||
|
|
|
|||
|
|
@ -28,11 +28,13 @@ use Illuminate\Support\Facades\Session;
|
|||
class OrdersController extends Controller
|
||||
{
|
||||
/**
|
||||
* index of orders (Bo)
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \App\Http\Requests\SortOrders $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(SortOrders $request)
|
||||
{
|
||||
// $orders = Order::orderBy('date', 'DESC')->get();
|
||||
$orders = $this->filterOrders($request);
|
||||
|
||||
$orders = $orders->paginate(10);
|
||||
|
|
@ -40,12 +42,17 @@ class OrdersController extends Controller
|
|||
return view('bo.orders.index', compact('orders'));
|
||||
}
|
||||
|
||||
/**
|
||||
* orders that ship today
|
||||
*
|
||||
* @param SortOrders $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function today(SortOrders $request)
|
||||
{
|
||||
// $orders = Order::orderBy('date', 'DESC')->get();
|
||||
$orders = $this->filterOrders($request);
|
||||
|
||||
// filter today
|
||||
// Filter today.
|
||||
$today = CarbonImmutable::now()->startOfDay();
|
||||
$orders = $orders->whereHas('timeslot', function ($q) use ($today) {
|
||||
$q->where('day', '=', $today->format('d/m/Y'));
|
||||
|
|
@ -53,10 +60,15 @@ class OrdersController extends Controller
|
|||
|
||||
|
||||
$orders = $orders->get();
|
||||
// paginate(20);
|
||||
return view('bo.orders.index', compact('orders', 'today'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter orders
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
protected function filterOrders(Request $request)
|
||||
{
|
||||
$orders = Order::query();
|
||||
|
|
@ -107,40 +119,47 @@ class OrdersController extends Controller
|
|||
/**
|
||||
* action de changement de statut vers l'avant
|
||||
* envoi de mails transctionnels
|
||||
* @param string $reference reference de la commande
|
||||
*
|
||||
* @param string $reference Reference de la commande.
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function changeStatus($reference)
|
||||
public function changeStatus(string $reference)
|
||||
{
|
||||
$order = Order::where('reference', $reference)->first();
|
||||
$order->status_id = $order->status_id + 1;
|
||||
$order->save();
|
||||
|
||||
// send confirm mail
|
||||
// Send confirm mail.
|
||||
Mail::to($order->customer->email)->send(new OrderStatusMail($order));
|
||||
|
||||
// return redirect()->route('bo.orders')->with('success', "Changement de status enregistré pour la commande " . $order->reference . ".");
|
||||
return back()->with('success', "Changement de status enregistré pour la commande " . $order->reference . ".");
|
||||
}
|
||||
|
||||
/**
|
||||
* mise au statut annulé d'une commande
|
||||
*
|
||||
* @param string $reference
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function cancelOrder($reference)
|
||||
public function cancelOrder(string $reference)
|
||||
{
|
||||
$order = Order::where('reference', $reference)->first();
|
||||
$order->status_id = 7;
|
||||
$order->save();
|
||||
|
||||
// return redirect()->route('bo.orders')->with('success', "La commande à été annulée.");
|
||||
return back()->with('success', "La commande " . $order->reference . " à été annulée.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated Supprimer cette méthode qui repose sur un modèle de donnée osolète.
|
||||
* ajout de produits à la commande
|
||||
* @todo : supprimer cette méthode qui repose sur un modèle de donnée osolète
|
||||
*
|
||||
* @param string $orderReference
|
||||
* @param integer $productId
|
||||
* @param integer $quantity
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function addProduct($orderReference, $productId, $quantity)
|
||||
public function addProduct(string $orderReference, int $productId, int $quantity)
|
||||
{
|
||||
$product = Product::findOrFail($productId);
|
||||
$order = Order::where('reference', $orderReference)->first();
|
||||
|
|
@ -159,7 +178,8 @@ class OrdersController extends Controller
|
|||
/**
|
||||
* front
|
||||
* récap panier du tunnel de commande
|
||||
* @todo : déplacer vers le controller idoine
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function recapOrder()
|
||||
{
|
||||
|
|
@ -169,18 +189,18 @@ class OrdersController extends Controller
|
|||
|
||||
$cartInfos = array(
|
||||
"totalTTC" => Cart::total(),
|
||||
// Total des taxes.
|
||||
'totalTVA' => Cart::tax(),
|
||||
// total des taxes
|
||||
// Total sans les taxes.
|
||||
'totalHT' => Cart::subtotal(),
|
||||
// total sans les taxes
|
||||
// Poids total des items.
|
||||
'totalweight' => Cart::weight(),
|
||||
// poids total des items
|
||||
// Total avant taxes et remises.
|
||||
'totalHTbefore' => Cart::priceTotal(),
|
||||
// total avant taxes et remises
|
||||
// Total des remises.
|
||||
'totaldiscount' => Cart::discount(),
|
||||
// total des remises
|
||||
// Nb de produits dans le cart.
|
||||
'countItems' => Cart::count(),
|
||||
// nb de produits dans le cart
|
||||
);
|
||||
|
||||
return view('sales.recap', compact('activestep', 'cart', 'cartInfos'));
|
||||
|
|
@ -189,13 +209,15 @@ class OrdersController extends Controller
|
|||
/**
|
||||
* front
|
||||
* Storing order from sales tunnel
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
// save
|
||||
// Save.
|
||||
Cart::instance('panier');
|
||||
$order = new Order();
|
||||
// generate order ref
|
||||
// Generate order ref.
|
||||
$order->reference = $this->generateOrderRef();
|
||||
$order->date = Carbon::now();
|
||||
$order->status_id = 1;
|
||||
|
|
@ -204,7 +226,7 @@ class OrdersController extends Controller
|
|||
|
||||
$order->save();
|
||||
|
||||
// order_id
|
||||
// Order_id.
|
||||
Cart::instance('panier');
|
||||
$cart = Cart::content();
|
||||
foreach ($cart as $cartItem) {
|
||||
|
|
@ -212,47 +234,48 @@ class OrdersController extends Controller
|
|||
$order_line->order_id = $order->id;
|
||||
$order_line->product_id = $cartItem->model->id;
|
||||
$order_line->quantity = $cartItem->qty;
|
||||
// gross unit price
|
||||
// Gross unit price.
|
||||
$order_line->unit_price = $cartItem->model->priceHt;
|
||||
// discount per unit
|
||||
// Discount per unit.
|
||||
$order_line->unit_discount = $cartItem->model->discountAmount;
|
||||
// tax rate for this line
|
||||
// Tax rate for this line.
|
||||
$order_line->tax_rate = $cartItem->taxRate;
|
||||
// tax amount par unit
|
||||
$order_line->unit_tax = round(( ($order_line->unit_price - $order_line->unit_discount) * ($order_line->tax_rate / 100) ) * 100) / 100;
|
||||
// discount amount for the line
|
||||
// Tax amount par unit.
|
||||
$order_line->unit_tax = round(
|
||||
(($order_line->unit_price - $order_line->unit_discount) * ($order_line->tax_rate / 100)) * 100
|
||||
) / 100;
|
||||
// Discount amount for the line.
|
||||
$order_line->total_discount = $order_line->unit_discount * $order_line->quantity;
|
||||
// gross amount for the line
|
||||
// Gross amount for the line.
|
||||
$order_line->total_ht = ($order_line->unit_price - $order_line->unit_discount) * $order_line->quantity;
|
||||
// tax amount for the line
|
||||
// Tax amount for the line.
|
||||
$order_line->total_tax = $order_line->unit_tax * $order_line->quantity;
|
||||
// total TTC avec remises de la ligne
|
||||
// Total TTC avec remises de la ligne.
|
||||
$order_line->total_ttc = $order_line->total_ht + $order_line->total_tax;
|
||||
|
||||
$order_line->save();
|
||||
}//end foreach
|
||||
|
||||
// empty cart
|
||||
// Empty cart.
|
||||
Cart::destroy();
|
||||
// then redirect
|
||||
// Then redirect.
|
||||
return redirect()->route('sales.pick-slot', ['reference' => $order->reference]);
|
||||
}
|
||||
|
||||
/**
|
||||
* generate order Reference
|
||||
* for a new order
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateOrderRef()
|
||||
{
|
||||
|
||||
// Avant
|
||||
// Str::uuid();
|
||||
// maintenant
|
||||
// format : YYYYMMDDHHMM000
|
||||
// Format : YYYYMMDDHHMM000.
|
||||
$now = Carbon::now();
|
||||
// count todays orders
|
||||
// Count todays orders.
|
||||
$countorders = Order::whereDate('created_at', Carbon::today())->count();
|
||||
// add one
|
||||
// Add one.
|
||||
$countorders++;
|
||||
$ref = $now->isoFormat('YYYYMMDDHHmm') . str_pad($countorders, 3, "0", STR_PAD_LEFT);
|
||||
return $ref;
|
||||
|
|
@ -260,8 +283,11 @@ class OrdersController extends Controller
|
|||
|
||||
/**
|
||||
* front tunnel de commande étape 3 : choix de créneau
|
||||
*
|
||||
* @param string $reference
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function timeSlotPick($reference)
|
||||
public function timeSlotPick(string $reference)
|
||||
{
|
||||
$activestep = 3;
|
||||
if (config('theme.multi_relay')) {
|
||||
|
|
@ -271,25 +297,81 @@ class OrdersController extends Controller
|
|||
}
|
||||
|
||||
$availCreneaux = array();
|
||||
// plus besoin car chargé par le composant vue.
|
||||
// $availCreneaux = $this->getAvailableCreneauxByShop($magasin->id);
|
||||
$order = Order::where('reference', '=', $reference)->firstOrFail();
|
||||
$order = Order::where('reference', '=', $reference)->firstOrFail();
|
||||
|
||||
return view('sales.pick-slot', compact('activestep', 'availCreneaux', 'order', 'magasin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* add timeslot by interval between start and end hour
|
||||
*
|
||||
* @param array $plage
|
||||
* @param integer $weekDay
|
||||
* @param CarbonImmutable $current
|
||||
* @param Magasin $magasin
|
||||
* @param CarbonImmutable $now
|
||||
* @param CarbonImmutable $today
|
||||
* @param CarbonInterval $delaiPrepa
|
||||
* @param CarbonInterval $interval
|
||||
* @param Carbon $currentTime
|
||||
* @param Carbon $endTime
|
||||
* @return array
|
||||
*/
|
||||
public function getAvailableCreneauxByShop($id)
|
||||
private function addCreneaux(
|
||||
array $plage,
|
||||
int $weekDay,
|
||||
CarbonImmutable $current,
|
||||
Magasin $magasin,
|
||||
CarbonImmutable $now,
|
||||
CarbonImmutable $today,
|
||||
CarbonInterval $delaiPrepa,
|
||||
CarbonInterval $interval,
|
||||
Carbon $currentTime,
|
||||
Carbon $endTime
|
||||
) {
|
||||
$retArray = array();
|
||||
do {
|
||||
$creneau = $currentTime->format('H:i');
|
||||
$nbtakens = $magasin->timeslots()
|
||||
->where('day', $current->format('d/m/Y'))
|
||||
->where('time', $creneau)->count();
|
||||
|
||||
if ($nbtakens >= $plage[$weekDay]['max_orders_per_interval']) {
|
||||
$isDispo = false;
|
||||
} else {
|
||||
$isDispo = true;
|
||||
}
|
||||
|
||||
if (
|
||||
$current->addHours($currentTime->format('H'))->addMinutes($currentTime->format('i')) <
|
||||
$now->add($delaiPrepa)
|
||||
) {
|
||||
$isDispo = false;
|
||||
}
|
||||
// Attention si la date est passée (today mais avant maintenant) : pas de créneau.
|
||||
if ($current > $today || $currentTime >= $now) {
|
||||
$retArray[] = array($creneau, $isDispo);
|
||||
}
|
||||
$currentTime->add($interval);
|
||||
} while ($currentTime <= $endTime);
|
||||
return $retArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* give array of available crenaux
|
||||
*
|
||||
* @param integer $id
|
||||
* @return array
|
||||
*/
|
||||
public function getAvailableCreneauxByShop(int $id)
|
||||
{
|
||||
// setting à stocker et réutiliser
|
||||
// Setting à stocker et réutiliser.
|
||||
$plage_days = Setting::where('key', 'order_withdrawal_period')->firstOrFail()->value;
|
||||
|
||||
$magasin = Magasin::findOrFail($id);
|
||||
$timeslotSettings = $magasin->timeslotSettings;
|
||||
// $timeslotSettings = TimeslotSetting::all();
|
||||
// fabriquons un tableau recap
|
||||
// Fabriquons un tableau recap.
|
||||
$plage = array();
|
||||
foreach ($timeslotSettings as $day) {
|
||||
$plage[$day->day_index] = array(
|
||||
|
|
@ -303,18 +385,14 @@ class OrdersController extends Controller
|
|||
);
|
||||
}
|
||||
|
||||
// génération des plages
|
||||
// start today
|
||||
// Génération des plages.
|
||||
// Start today.
|
||||
$today = CarbonImmutable::now()->startOfDay();
|
||||
$weekDay = $today->weekday();
|
||||
// final boundary (permet de limiter la liste des jours d'exception)
|
||||
// Final boundary (permet de limiter la liste des jours d'exception).
|
||||
$finalday = $today->add($plage_days, 'day');
|
||||
$now = CarbonImmutable::now();
|
||||
// jours exceptions
|
||||
// $noCollectDays = CollecteException::where('magasin_id',$magasin->id)
|
||||
// ->whereDate('date', '>', $now)
|
||||
// ->whereDate('date', '<=', $finalday)
|
||||
// ->orderBy('date')->get();
|
||||
// Jours exceptions.
|
||||
$noCollectDays = $magasin->collecteExceptions()
|
||||
->whereDate('date', '>', $now)
|
||||
->whereDate('date', '<=', $finalday)
|
||||
|
|
@ -325,12 +403,11 @@ class OrdersController extends Controller
|
|||
$availCreneaux = array();
|
||||
|
||||
for ($i = 0; $i < $plage_days; $i++) {
|
||||
/** @var Carbon */
|
||||
$current = $today->add($i, 'day');
|
||||
$weekDay = $current->weekday();
|
||||
$interval = CarbonInterval::createFromFormat('h:i', $plage[$weekDay]['interval'] ?? '00:15');
|
||||
|
||||
// si c'est un jour exception skip
|
||||
// Si c'est un jour exception skip.
|
||||
$skip = false;
|
||||
foreach ($noCollectDays as $not_today) {
|
||||
if ($current->isSameDay($not_today->date)) {
|
||||
|
|
@ -340,63 +417,63 @@ class OrdersController extends Controller
|
|||
if ($skip) {
|
||||
continue;
|
||||
}
|
||||
// matinée
|
||||
$availCreneaux[$current->format('d/m/Y')] = array();
|
||||
// Matinée.
|
||||
if (!empty($plage[$weekDay]['morning_start'])) {
|
||||
$currentTime = Carbon::createFromTimeString($plage[$weekDay]['morning_start']);
|
||||
$endTime = Carbon::createFromTimeString($plage[$weekDay]['morning_end']);
|
||||
do {
|
||||
$creneau = $currentTime->format('H:i');
|
||||
$nbtakens = $magasin->timeslots()
|
||||
->where('day', $current->format('d/m/Y'))
|
||||
->where('time', $creneau)->count();
|
||||
|
||||
// $nbtakens = Timeslot::where('day', $current->format('d/m/Y'))
|
||||
// ->where('time', $creneau)->count();
|
||||
if ($nbtakens >= $plage[$weekDay]['max_orders_per_interval']) {
|
||||
$isDispo = false;
|
||||
} else {
|
||||
$isDispo = true;
|
||||
}
|
||||
$morningCreneaux = $this->addCreneaux(
|
||||
$plage,
|
||||
$weekDay,
|
||||
$current,
|
||||
$magasin,
|
||||
$now,
|
||||
$today,
|
||||
$delaiPrepa,
|
||||
$interval,
|
||||
$currentTime,
|
||||
$endTime
|
||||
);
|
||||
|
||||
if ($current->addHours($currentTime->format('H'))->addMinutes($currentTime->format('i')) < $now->add($delaiPrepa)) {
|
||||
$isDispo = false;
|
||||
}
|
||||
// attention si la date est passée (today mais avant maintenant) : pas de créneau
|
||||
if ($current > $today || $currentTime >= $now) {
|
||||
$availCreneaux[$current->format('d/m/Y')][] = array($creneau,$isDispo);
|
||||
}
|
||||
$currentTime->add($interval);
|
||||
} while ($currentTime <= $endTime);
|
||||
}//end if
|
||||
// aprem
|
||||
$availCreneaux[$current->format('d/m/Y')] = array_merge(
|
||||
$availCreneaux[$current->format('d/m/Y')],
|
||||
$morningCreneaux
|
||||
);
|
||||
} //end if
|
||||
// Aprem.
|
||||
if (!empty($plage[$weekDay]['afternoon_start'])) {
|
||||
$currentTime = Carbon::createFromTimeString($plage[$weekDay]['afternoon_start']);
|
||||
$endTime = Carbon::createFromTimeString($plage[$weekDay]['afternoon_end']);
|
||||
do {
|
||||
$creneau = $currentTime->format('H:i');
|
||||
$nbtakens = Timeslot::where('day', $current->format('d/m/Y'))->where('time', $creneau)->count();
|
||||
if ($nbtakens >= $plage[$weekDay]['max_orders_per_interval']) {
|
||||
$isDispo = false;
|
||||
} else {
|
||||
$isDispo = true;
|
||||
}
|
||||
|
||||
if ($current->addHours($currentTime->format('H'))->addMinutes($currentTime->format('i')) < $now->add($delaiPrepa)) {
|
||||
$isDispo = false;
|
||||
}
|
||||
$afternoonCreneaux = $this->addCreneaux(
|
||||
$plage,
|
||||
$weekDay,
|
||||
$current,
|
||||
$magasin,
|
||||
$now,
|
||||
$today,
|
||||
$delaiPrepa,
|
||||
$interval,
|
||||
$currentTime,
|
||||
$endTime
|
||||
);
|
||||
|
||||
// attention si la date est passée (today mais avant maintenant) : pas de créneau
|
||||
if ($current > $today || $currentTime >= $now) {
|
||||
$availCreneaux[$current->format('d/m/Y')][] = array($creneau,$isDispo);
|
||||
}
|
||||
$currentTime->add($interval);
|
||||
} while ($currentTime <= $endTime);
|
||||
}//end if
|
||||
$availCreneaux[$current->format('d/m/Y')] = array_merge(
|
||||
$availCreneaux[$current->format('d/m/Y')],
|
||||
$afternoonCreneaux
|
||||
);
|
||||
} //end if
|
||||
}//end for
|
||||
return $availCreneaux;
|
||||
}
|
||||
|
||||
// call ajax pour le composant vue de timeslots
|
||||
/**
|
||||
* Call ajax pour le composant vue de timeslots.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function getAvailableCreneaux(Request $request)
|
||||
{
|
||||
return $this->getAvailableCreneauxByShop($request->id);
|
||||
|
|
@ -406,6 +483,9 @@ class OrdersController extends Controller
|
|||
* front
|
||||
* enregistrement du créneau de collect
|
||||
* et validation de la commande
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function setTimeSlot(Request $request)
|
||||
{
|
||||
|
|
@ -423,8 +503,8 @@ class OrdersController extends Controller
|
|||
$order = Order::where('reference', '=', $reference)->firstOrFail();
|
||||
|
||||
if ($order->status_id == 1) {
|
||||
// on ne traite l'enregistrement que pour les commandes en attente venant de l'étape de récap
|
||||
// save timeslot
|
||||
// On ne traite l'enregistrement que pour les commandes en attente venant de l'étape de récap.
|
||||
// Save timeslot.
|
||||
$timeslot = Timeslot::firstOrNew(['order_id' => $order->id]);
|
||||
$timeslot->order_id = $order->id;
|
||||
$timeslot->magasin_id = $magasin_id;
|
||||
|
|
@ -432,14 +512,14 @@ class OrdersController extends Controller
|
|||
$timeslot->time = $tstime;
|
||||
$timeslot->save();
|
||||
|
||||
// save order status
|
||||
// Save order status.
|
||||
$order->status_id = 3;
|
||||
$order->save();
|
||||
|
||||
// send confirm mail
|
||||
// Send confirm mail.
|
||||
Mail::to($order->customer->email)->queue(new OrderConfirmMail($order));
|
||||
|
||||
// envoi du mail de confirmation aux admins site
|
||||
// Envoi du mail de confirmation aux admins site.
|
||||
$toMailSetting = Setting::where('key', 'send_order_confirm_mail_to')->first();
|
||||
if (empty($toMailSetting->value)) {
|
||||
$toMail = config('mail.from.address');
|
||||
|
|
@ -448,17 +528,24 @@ class OrdersController extends Controller
|
|||
}
|
||||
Mail::to($toMail)->queue(new OrderConfirmAdminMail($order));
|
||||
|
||||
// export commande
|
||||
// Export commande.
|
||||
if (config('bosettings.regate_orders')) {
|
||||
CsvOrderWrite::dispatch($order);
|
||||
}
|
||||
}//end if
|
||||
|
||||
// redirect to final confirmation
|
||||
// Redirect to final confirmation.
|
||||
return redirect()->route('sales.confirm', ['reference' => $order->reference]);
|
||||
}
|
||||
|
||||
public function generateOrder($reference)
|
||||
/**
|
||||
* generate Order
|
||||
* Test method
|
||||
*
|
||||
* @param string $reference
|
||||
* @return void
|
||||
*/
|
||||
public function generateOrder(string $reference)
|
||||
{
|
||||
$order = Order::where('reference', '=', $reference)->with('lines')->firstOrFail();
|
||||
$job = new CsvOrderWrite($order);
|
||||
|
|
@ -469,8 +556,11 @@ class OrdersController extends Controller
|
|||
/**
|
||||
* front
|
||||
* page de confirmation de commande
|
||||
*
|
||||
* @param string $reference
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function confirmOrder($reference)
|
||||
public function confirmOrder(string $reference)
|
||||
{
|
||||
$activestep = 4;
|
||||
|
||||
|
|
@ -486,9 +576,12 @@ class OrdersController extends Controller
|
|||
/**
|
||||
* bo
|
||||
* ajx : affichage d'infos sur un client
|
||||
* @todo : déplacer dans le controller idoine
|
||||
*
|
||||
* @param integer $id
|
||||
* @param string|null $mode
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function getCustomerInfo($id, $mode = null)
|
||||
public function getCustomerInfo(int $id, string $mode = null)
|
||||
{
|
||||
$cust = Customers::findOrFail($id);
|
||||
if (!is_null($mode)) {
|
||||
|
|
@ -504,9 +597,12 @@ class OrdersController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* bo : page détatil commande
|
||||
* bo : page détail commande
|
||||
*
|
||||
* @param string $reference
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function orderDetail($reference)
|
||||
public function orderDetail(string $reference)
|
||||
{
|
||||
$order = Order::where('reference', '=', $reference)->firstOrFail();
|
||||
return view('bo.orders.detail', compact('order'));
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@ use Illuminate\Support\Facades\File;
|
|||
class ProductsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Bo index page for products
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
|
@ -40,13 +43,12 @@ class ProductsController extends Controller
|
|||
}
|
||||
$products = $products->paginate(10);
|
||||
|
||||
// ici récupération des infos additionnelles pour affichage dans la liste
|
||||
// @todo : parametrer l'occurence de ces affichages car ça n'aura aucun sens selon le type de produit
|
||||
// Ici récupération des infos additionnelles pour affichage dans la liste.
|
||||
foreach ($products as &$product) {
|
||||
if (!empty($product->product_type)) {
|
||||
$product->additionnalProductInfo = $product->additionnalProductInfo($product->product_type);
|
||||
if ($product->additionnalProductInfo === null) {
|
||||
// n'existe pas on renseigne un vide
|
||||
// N'existe pas on renseigne un vide.
|
||||
$product_type = $product->product_type;
|
||||
$modelClass = 'App\Models\\' . ucfirst($product_type);
|
||||
$product->$product_type = new $modelClass();
|
||||
|
|
@ -58,13 +60,14 @@ class ProductsController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* create à product
|
||||
* Show the form for creating a new resource.
|
||||
* @param string $product_type
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create($product_type = null)
|
||||
public function create(string $product_type = null)
|
||||
{
|
||||
if (!empty($product_type) && !array_key_exists($product_type, config('theme.enum_product_types'))) {
|
||||
abort(404, "Cette page n'existe pas.");
|
||||
// return redirect()->route('bo.products.index');
|
||||
}
|
||||
$modelClass = 'App\Models\\' . ucfirst($product_type);
|
||||
$product = new Product();
|
||||
|
|
@ -78,12 +81,13 @@ class ProductsController extends Controller
|
|||
|
||||
/**
|
||||
* store a new product
|
||||
* @todo : manage tags and associated products
|
||||
* @todo : enregistrer unité de vente, poids et unité de poids
|
||||
*
|
||||
* @param ProductRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(ProductRequest $request)
|
||||
{
|
||||
// products fields
|
||||
// Products fields.
|
||||
$name = $request->name;
|
||||
$description = $request->description;
|
||||
$picture = $request->picture;
|
||||
|
|
@ -98,15 +102,17 @@ class ProductsController extends Controller
|
|||
$weight = $request->weight;
|
||||
$weight_unit = $request->weight_unit;
|
||||
$status = $request->status === null ? 0 : 1;
|
||||
$orderable_start = $request->orderable_start_date === null ? null : $request->orderable_start_date . " " . $request->orderable_start_time;
|
||||
$orderable_end = $request->orderable_end_date === null ? null : $request->orderable_end_date . " " . $request->orderable_end_time;
|
||||
$orderable_start = $request->orderable_start_date === null ? null
|
||||
: $request->orderable_start_date . " " . $request->orderable_start_time;
|
||||
$orderable_end = $request->orderable_end_date === null ? null
|
||||
: $request->orderable_end_date . " " . $request->orderable_end_time;
|
||||
$star = $request->star === null ? 0 : 1;
|
||||
$slug = Str::slug($name);
|
||||
$rangeId = $request->range_id;
|
||||
$taxRateId = $request->tax_rate_id;
|
||||
|
||||
|
||||
// Check si le slug existe déjà dans cette gamme de produits
|
||||
// Check si le slug existe déjà dans cette gamme de produits.
|
||||
$slugExist = Product::where([
|
||||
['range_id', $rangeId],
|
||||
['slug', $slug]
|
||||
|
|
@ -140,7 +146,7 @@ class ProductsController extends Controller
|
|||
$product->tax_rate_id = $taxRateId;
|
||||
$product->save();
|
||||
|
||||
// Check si le slug existe dans la table old_slugs, auquel cas il est attribué a ce nouveau produit
|
||||
// Check si le slug existe dans la table old_slugs, auquel cas il est attribué a ce nouveau produit.
|
||||
$oldSlug = OldSlug::where('slug', $slug)->first();
|
||||
if ($oldSlug && $oldSlug->product_id !== $product->id) {
|
||||
$oldSlug->product_id = $product->id;
|
||||
|
|
@ -163,7 +169,7 @@ class ProductsController extends Controller
|
|||
$product->save();
|
||||
}
|
||||
|
||||
// ajout des infos additionnelles
|
||||
// Ajout des infos additionnelles.
|
||||
$product_type = $request->product_type;
|
||||
|
||||
if ($product_type !== null) {
|
||||
|
|
@ -174,22 +180,27 @@ class ProductsController extends Controller
|
|||
}
|
||||
|
||||
|
||||
// additionnal product info (foodProduct)
|
||||
// Additionnal product info (foodProduct).
|
||||
return redirect()->route('bo.products.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* edit an existing product
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(int $id)
|
||||
{
|
||||
$product = Product::findOrFail($id);
|
||||
if (!empty($product->product_type)) {
|
||||
$product->additionnalProductInfo = $product->additionnalProductInfo($product->product_type);
|
||||
// above lines equivalent to :
|
||||
// $product = Product::with('additionnalProductInfo')->findOrFail($id);
|
||||
/**
|
||||
* Above lines equivalent to
|
||||
* $product = Product::with('additionnalProductInfo')->findOrFail($id);
|
||||
*/
|
||||
if ($product->additionnalProductInfo === null) {
|
||||
// n'existe pas on renseigne un vide
|
||||
// N'existe pas on renseigne un vide.
|
||||
$product_type = $product->product_type;
|
||||
$modelClass = 'App\Models\\' . ucfirst($product_type);
|
||||
$product->$product_type = new $modelClass();
|
||||
|
|
@ -205,22 +216,30 @@ class ProductsController extends Controller
|
|||
$selectedProds = $product->products;
|
||||
$existingProds = $existingProds->diff($selectedProds);
|
||||
|
||||
return view('bo.products.edit', compact('product', 'ranges', 'taxes', 'existingTags', 'selectedtags', 'existingProds', 'selectedProds'));
|
||||
return view('bo.products.edit', compact(
|
||||
'product',
|
||||
'ranges',
|
||||
'taxes',
|
||||
'existingTags',
|
||||
'selectedtags',
|
||||
'existingProds',
|
||||
'selectedProds'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* update an existing product
|
||||
* Update the specified resource.
|
||||
*
|
||||
* @param \App\Models\Product $product
|
||||
* @param ProductRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Product $product, ProductRequest $request)
|
||||
{
|
||||
|
||||
// $product = Product::findOrFail($id);
|
||||
$orderable_end_time = $request->orderable_end_time === null ? "23:59" : $request->orderable_end_time;
|
||||
|
||||
$name = $request->name;
|
||||
$description = $request->description;
|
||||
$picture = $request->picture;
|
||||
$picture_large = $request->picture_large;
|
||||
$price = $request->price;
|
||||
$invoicing_unit = $request->invoicing_unit;
|
||||
$priceBuy = $request->price_buy;
|
||||
|
|
@ -231,59 +250,22 @@ class ProductsController extends Controller
|
|||
$weight = $request->weight;
|
||||
$weight_unit = $request->weight_unit;
|
||||
$status = $request->status === null ? 0 : 1;
|
||||
$orderable_start = $request->orderable_start_date === null ? null : $request->orderable_start_date . " " . $request->orderable_start_time;
|
||||
$orderable_end = $request->orderable_end_date === null ? null : $request->orderable_end_date . " " . $orderable_end_time;
|
||||
$orderable_start = $request->orderable_start_date === null ? null
|
||||
: $request->orderable_start_date . " " . $request->orderable_start_time;
|
||||
$orderable_end = $request->orderable_end_date === null ? null
|
||||
: $request->orderable_end_date . " " . $orderable_end_time;
|
||||
$star = $request->star === null ? 0 : 1;
|
||||
$slug = Str::slug($name);
|
||||
$rangeId = $request->range_id;
|
||||
$taxRateId = $request->tax_rate_id;
|
||||
$tags = $request->tags;
|
||||
|
||||
// Check si le slug existe déjà dans cette gamme de produits
|
||||
$slugExist = Product::where([
|
||||
['range_id', $rangeId],
|
||||
['slug', $slug],
|
||||
['id', '<>', $product->id]
|
||||
])->first();
|
||||
$this->checkSlugExistsWithinRange($rangeId, $slug, $product->id, $request);
|
||||
|
||||
if ($slugExist) {
|
||||
return redirect()->back()
|
||||
->withInput($request->input())
|
||||
->withErrors("Erreur : un produit avec le slug d'accès \"" . $slug .
|
||||
"\" éxiste déjà. Veuillez changer le nom du produit.");
|
||||
}
|
||||
|
||||
$str_random = Str::random(5);
|
||||
|
||||
if ($picture !== null) {
|
||||
if ($product->picture !== null && file_exists(public_path('images/produits/') . $product->picture)) {
|
||||
unlink(public_path('images/produits/') . $product->picture);
|
||||
}
|
||||
$imageName = $product->id . '_' . $str_random . '.' . $picture->extension();
|
||||
$picture->move(public_path('images/produits'), $imageName);
|
||||
$product->picture = $imageName;
|
||||
}
|
||||
|
||||
if ($picture_large !== null) {
|
||||
if ($product->picture_large !== null && file_exists(public_path('images/produits/') . $product->picture_large)) {
|
||||
unlink(public_path('images/produits/') . $product->picture_large);
|
||||
}
|
||||
$imageName = $product->id . '_' . $str_random . '_large.' . $picture_large->extension();
|
||||
$picture_large->move(public_path('images/produits'), $imageName);
|
||||
$product->picture_large = $imageName;
|
||||
}
|
||||
$this->manageProductImages($request->picture, $product, $request->picture_large);
|
||||
|
||||
$product->name = $name;
|
||||
|
||||
if ($product->slug != $slug) {
|
||||
$exist = OldSlug::where('slug', $product->slug)->first();
|
||||
if ($exist === null) {
|
||||
$oldSlug = new OldSlug();
|
||||
$oldSlug->product_id = $product->id;
|
||||
$oldSlug->slug = $product->slug;
|
||||
$oldSlug->save();
|
||||
}
|
||||
}
|
||||
$this->saveNewSlugForProduct($product, $slug);
|
||||
|
||||
$product->description = $description;
|
||||
$product->price = $price;
|
||||
|
|
@ -304,67 +286,190 @@ class ProductsController extends Controller
|
|||
$product->tax_rate_id = $taxRateId;
|
||||
$product->save();
|
||||
|
||||
// Check si le slug existe dans la table old_slug, auquel cas il est attribué a ce nouveau produit
|
||||
$oldSlug = OldSlug::where('slug', $slug)->first();
|
||||
if ($oldSlug) {
|
||||
$oldSlug->delete();
|
||||
}
|
||||
// Check si le slug existe dans la table old_slug, auquel cas il est attribué a ce nouveau produit.
|
||||
$this->cleanOldSlug($slug);
|
||||
|
||||
// ajout des infos additionnelles
|
||||
// Ajout des infos additionnelles.
|
||||
$product_type = $request->product_type;
|
||||
|
||||
// save additionnal
|
||||
// Save additionnal.
|
||||
if ($product_type !== null) {
|
||||
$methodName = "save" . ucfirst($product_type);
|
||||
$this->$methodName($request, $product->id);
|
||||
}
|
||||
|
||||
// tags associés
|
||||
if (!empty($tags)) {
|
||||
$arTagIds = array();
|
||||
foreach ($tags as $tag) {
|
||||
$oTag = json_decode($tag);
|
||||
if (empty($oTag->id)) {
|
||||
// we need a new tag
|
||||
$arTagIds[] = $this->storeTag($oTag);
|
||||
} else {
|
||||
$arTagIds[] = $oTag->id;
|
||||
}
|
||||
}
|
||||
// prise en charge de la liaison avec les produits
|
||||
$product->tags()->sync($arTagIds);
|
||||
} else {
|
||||
$product->tags()->sync(array());
|
||||
}
|
||||
// Tags associés.
|
||||
$this->syncTags($request->tags, $product);
|
||||
|
||||
// produits associés
|
||||
if (!empty($request->prods)) {
|
||||
$productIds = explode(",", $request->prods);
|
||||
// prise en charge de la liaison avec les produits
|
||||
$product->products()->sync($productIds);
|
||||
} else {
|
||||
$product->products()->sync(array());
|
||||
}
|
||||
// Produits associés.
|
||||
$this->syncProduitsAssocies($request->prods, $product);
|
||||
|
||||
return redirect()->route('bo.products.edit', $product->id)->with('success', 'Modifications enregistrés !');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if slug already exists, if so redirect
|
||||
*
|
||||
* @param integer $rangeId
|
||||
* @param string $slug
|
||||
* @param integer $productId
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse|void
|
||||
*/
|
||||
private function checkSlugExistsWithinRange(int $rangeId, string $slug, int $productId, Request $request)
|
||||
{
|
||||
// Check si le slug existe déjà dans cette gamme de produits.
|
||||
$slugExist = Product::where([
|
||||
['range_id', $rangeId],
|
||||
['slug', $slug],
|
||||
['id', '<>', $productId]
|
||||
])->first();
|
||||
|
||||
if ($slugExist) {
|
||||
return redirect()->back()
|
||||
->withInput($request->input())
|
||||
->withErrors("Erreur : un produit avec le slug d'accès \"" . $slug .
|
||||
"\" éxiste déjà. Veuillez changer le nom du produit.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If new slug for product then save oldslug
|
||||
*
|
||||
* @param Product $product
|
||||
* @param string $slug
|
||||
* @return void
|
||||
*/
|
||||
private function saveNewSlugForProduct(Product $product, string $slug)
|
||||
{
|
||||
if ($product->slug != $slug) {
|
||||
$exist = OldSlug::where('slug', $product->slug)->first();
|
||||
if ($exist === null) {
|
||||
$oldSlug = new OldSlug();
|
||||
$oldSlug->product_id = $product->id;
|
||||
$oldSlug->slug = $product->slug;
|
||||
$oldSlug->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* clean oldslug if exists
|
||||
*
|
||||
* @param string $slug
|
||||
* @return void
|
||||
*/
|
||||
private function cleanOldSlug(string $slug)
|
||||
{
|
||||
// Check si le slug existe dans la table old_slug, auquel cas il est attribué a ce nouveau produit.
|
||||
$oldSlug = OldSlug::where('slug', $slug)->first();
|
||||
if ($oldSlug) {
|
||||
$oldSlug->delete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store and update saved images on product
|
||||
*
|
||||
* @param UploadedFile|null $picture
|
||||
* @param Product $product
|
||||
* @param UploadedFile|null $picture_large
|
||||
* @return void
|
||||
*/
|
||||
private function manageProductImages($picture, Product &$product, $picture_large)
|
||||
{
|
||||
|
||||
$str_random = Str::random(5);
|
||||
|
||||
if ($picture !== null) {
|
||||
if (
|
||||
$product->picture !== null &&
|
||||
file_exists(public_path('images/produits/') . $product->picture)
|
||||
) {
|
||||
unlink(public_path('images/produits/') . $product->picture);
|
||||
}
|
||||
$imageName = $product->id . '_' . $str_random . '.' . $picture->extension();
|
||||
$picture->move(public_path('images/produits'), $imageName);
|
||||
$product->picture = $imageName;
|
||||
}
|
||||
|
||||
if ($picture_large !== null) {
|
||||
if (
|
||||
$product->picture_large !== null &&
|
||||
file_exists(public_path('images/produits/') . $product->picture_large)
|
||||
) {
|
||||
unlink(public_path('images/produits/') . $product->picture_large);
|
||||
}
|
||||
$imageName = $product->id . '_' . $str_random . '_large.' . $picture_large->extension();
|
||||
$picture_large->move(public_path('images/produits'), $imageName);
|
||||
$product->picture_large = $imageName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sync tags to product
|
||||
*
|
||||
* @param array $tags
|
||||
* @param Product $product
|
||||
* @return void
|
||||
*/
|
||||
private function syncTags(array $tags, Product &$product)
|
||||
{
|
||||
if (!empty($tags)) {
|
||||
$arTagIds = array();
|
||||
foreach ($tags as $tag) {
|
||||
$oTag = json_decode($tag);
|
||||
if (empty($oTag->id)) {
|
||||
// We need a new tag.
|
||||
$arTagIds[] = $this->storeTag($oTag);
|
||||
} else {
|
||||
$arTagIds[] = $oTag->id;
|
||||
}
|
||||
}
|
||||
// Prise en charge de la liaison avec les produits.
|
||||
$product->tags()->sync($arTagIds);
|
||||
} else {
|
||||
$product->tags()->sync(array());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sync associated products to product
|
||||
*
|
||||
* @param string $prods
|
||||
* @param Product $product
|
||||
* @return void
|
||||
*/
|
||||
private function syncProduitsAssocies(string $prods, Product $product)
|
||||
{
|
||||
if (!empty($prods)) {
|
||||
$productIds = explode(",", $prods);
|
||||
// Prise en charge de la liaison avec les produits.
|
||||
$product->products()->sync($productIds);
|
||||
} else {
|
||||
$product->products()->sync(array());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to store a new tag if necessary
|
||||
* Otherwise retreive an existing tag to associate its id
|
||||
*
|
||||
* @param \App\Models\Tag $oTag
|
||||
* @return integer
|
||||
*/
|
||||
public function storeTag($oTag)
|
||||
public function storeTag(Tag $oTag)
|
||||
{
|
||||
$slug = Str::slug($oTag->label);
|
||||
$tag = Tag::where('slug', $slug)->first();
|
||||
if ($tag === null) {
|
||||
// si on pas encore ce tag on le crée
|
||||
$tag = new Tag();
|
||||
$tag->label = $oTag->label;
|
||||
$tag->slug = Str::slug($oTag->label);
|
||||
// Si on pas encore ce tag on le crée.
|
||||
$tag = new Tag();
|
||||
$tag->label = $oTag->label;
|
||||
$tag->slug = Str::slug($oTag->label);
|
||||
// A new tag is published by default.
|
||||
$tag->status = 1;
|
||||
// a new tag is published by default
|
||||
$tag->order = TagsController::getLastOrder();
|
||||
$tag->order = TagsController::getLastOrder();
|
||||
$tag->save();
|
||||
}
|
||||
return $tag->id;
|
||||
|
|
@ -372,16 +477,21 @@ class ProductsController extends Controller
|
|||
|
||||
/**
|
||||
* destroy a product (soft delete)
|
||||
* @todo : manage liaisons
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$product = Product::findOrFail($id);
|
||||
|
||||
if ($product->picture !== null && file_exists(public_path('images/produits/') . $product->picture)) {
|
||||
unlink(public_path('images/produits/') . $product->picture);
|
||||
}
|
||||
if ($product->picture_large !== null && file_exists(public_path('images/produits/') . $product->picture_large)) {
|
||||
if (
|
||||
$product->picture_large !== null &&
|
||||
file_exists(public_path('images/produits/') . $product->picture_large)
|
||||
) {
|
||||
unlink(public_path('images/produits/') . $product->picture_large);
|
||||
}
|
||||
|
||||
|
|
@ -393,6 +503,9 @@ class ProductsController extends Controller
|
|||
|
||||
/**
|
||||
* check if inco data exists
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function checkIncoData(Request $request)
|
||||
{
|
||||
|
|
@ -400,7 +513,7 @@ class ProductsController extends Controller
|
|||
$xmlInco = XmlInco::find($id);
|
||||
|
||||
if (!empty($xmlInco)) {
|
||||
// we have data
|
||||
// We have data.
|
||||
$hasInco = __("Des données Inco sont disponibles, souhaitez vous les associer à ce produit ?");
|
||||
$preparedImages = $this->prepareIncoImages($xmlInco->picture);
|
||||
return view('bo.products.load-inco', compact('hasInco', 'xmlInco', 'preparedImages'));
|
||||
|
|
@ -409,6 +522,12 @@ class ProductsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show prepared images
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function getPrepareIncoImages(Request $request)
|
||||
{
|
||||
$picture = $request->picture;
|
||||
|
|
@ -417,20 +536,22 @@ class ProductsController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* prepare Inco Images
|
||||
* prepared images
|
||||
*
|
||||
* @param array $picture
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function prepareIncoImages($picture)
|
||||
public function prepareIncoImages(array $picture)
|
||||
{
|
||||
|
||||
$preparedImages = array();
|
||||
|
||||
foreach ($picture as $incoImage) {
|
||||
// charge
|
||||
// Charge.
|
||||
if (File::exists(storage_path($incoImage))) {
|
||||
$imagePath = storage_path($incoImage);
|
||||
// redimensionne
|
||||
// create mask
|
||||
// Resize original image into mask
|
||||
// Redimensionne.
|
||||
// Create mask.
|
||||
// Resize original image into mask.
|
||||
$this->resizeImg(
|
||||
$imagePath,
|
||||
config('theme.product_image_large_maxwidth'),
|
||||
|
|
@ -455,7 +576,16 @@ class ProductsController extends Controller
|
|||
/**
|
||||
* redimensionne une image dans un masque
|
||||
*/
|
||||
private function resizeImg($imagePath, $maskWidth, $maskHeight, $resizedName)
|
||||
/**
|
||||
* redimensionne une image dans un masque
|
||||
*
|
||||
* @param string $imagePath
|
||||
* @param integer $maskWidth
|
||||
* @param integer $maskHeight
|
||||
* @param string $resizedName
|
||||
* @return boolean|void
|
||||
*/
|
||||
private function resizeImg(string $imagePath, int $maskWidth, int $maskHeight, string $resizedName)
|
||||
{
|
||||
// ---- création du masque
|
||||
$mask = imagecreatetruecolor($maskWidth, $maskHeight);
|
||||
|
|
@ -499,16 +629,25 @@ class ProductsController extends Controller
|
|||
imagesavealpha($resizeImg, true);
|
||||
imagecopyresampled($resizeImg, $img, 0, 0, 0, 0, $finalWidth, $finalHeight, $imgWidth, $imgHeight);
|
||||
|
||||
// ---- Copie l'image redimensionnée dans le mask
|
||||
imagecopy($mask, $resizeImg, ($maskWidth - $finalWidth) / 2, ($maskHeight - $finalHeight) / 2, 0, 0, imagesx($resizeImg), imagesy($resizeImg));
|
||||
// Copie l'image redimensionnée dans le mask.
|
||||
imagecopy(
|
||||
$mask,
|
||||
$resizeImg,
|
||||
($maskWidth - $finalWidth) / 2,
|
||||
($maskHeight - $finalHeight) / 2,
|
||||
0,
|
||||
0,
|
||||
imagesx($resizeImg),
|
||||
imagesy($resizeImg)
|
||||
);
|
||||
imagealphablending($mask, false);
|
||||
imagesavealpha($mask, true);
|
||||
|
||||
// écrit dans storage/app/public
|
||||
// ---- Créer le fichier final
|
||||
// Ecrit dans storage/app/public.
|
||||
// Créer le fichier final.
|
||||
imagepng($mask, storage_path('app/public/inco/images/' . $resizedName), 5);
|
||||
|
||||
// ---- Libère la mémoire associée aux images manipulées
|
||||
// Libère la mémoire associée aux images manipulées.
|
||||
imagedestroy($img);
|
||||
imagedestroy($resizeImg);
|
||||
imagedestroy($mask);
|
||||
|
|
@ -517,6 +656,12 @@ class ProductsController extends Controller
|
|||
/**
|
||||
* set une image préparée comme image du produit
|
||||
*/
|
||||
/**
|
||||
* set une image préparée comme image du produit
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \App\Models\Product
|
||||
*/
|
||||
public function setIncoImage(Request $request)
|
||||
{
|
||||
$imagePath = $request->picture;
|
||||
|
|
@ -527,7 +672,7 @@ class ProductsController extends Controller
|
|||
$product = Product::findOrFail($product_id);
|
||||
|
||||
$str_random = Str::random(5);
|
||||
// default is large image
|
||||
// Default is large image.
|
||||
$finalImageName = $product->id . '_' . $str_random . '_large.' . File::extension($imagePath);
|
||||
|
||||
$productimagespath = public_path('images/produits');
|
||||
|
|
@ -538,20 +683,23 @@ class ProductsController extends Controller
|
|||
|
||||
File::copy($imagePath, $productimagespath . "/" . $finalImageName);
|
||||
|
||||
// suppression de l'ancien fichier
|
||||
if ($product->picture_large !== null && file_exists(public_path('images/produits/') . $product->picture_large)) {
|
||||
// Suppression de l'ancien fichier.
|
||||
if (
|
||||
$product->picture_large !== null &&
|
||||
file_exists(public_path('images/produits/') . $product->picture_large)
|
||||
) {
|
||||
unlink(public_path('images/produits/') . $product->picture_large);
|
||||
}
|
||||
|
||||
$product->picture_large = $finalImageName;
|
||||
|
||||
|
||||
// now set small image
|
||||
// Now set small image.
|
||||
$imagePath = str_replace("_large", "_small", $imagePath);
|
||||
$finalImageName = $product->id . '_' . $str_random . '.' . File::extension($imagePath);
|
||||
File::copy($imagePath, $productimagespath . "/" . $finalImageName);
|
||||
|
||||
// suppression de l'ancien fichier
|
||||
// Suppression de l'ancien fichier.
|
||||
if ($product->picture !== null && file_exists(public_path('images/produits/') . $product->picture)) {
|
||||
unlink(public_path('images/produits/') . $product->picture);
|
||||
}
|
||||
|
|
@ -560,15 +708,17 @@ class ProductsController extends Controller
|
|||
|
||||
$product->save();
|
||||
|
||||
// @TODO : envoyer une réponse pour maj de l'interface
|
||||
return $product;
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to update additionnal product info
|
||||
* foodProduct
|
||||
*
|
||||
* @param Request $request
|
||||
* @param integer $product_id
|
||||
* @return void
|
||||
*/
|
||||
public function saveFoodProduct(Request $request, $product_id)
|
||||
public function saveFoodProduct(Request $request, int $product_id)
|
||||
{
|
||||
$foodProduct = FoodProduct::firstOrNew([
|
||||
'product_id' => $product_id,
|
||||
|
|
@ -620,11 +770,17 @@ class ProductsController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* helper method to update additionnal product info
|
||||
* toolProduct
|
||||
* helper method to update toolproduct info
|
||||
*
|
||||
* @param Request $request
|
||||
* @param integer $product_id
|
||||
* @return void
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
*/
|
||||
public function saveToolProduct(Request $request, $product_id)
|
||||
public function saveToolProduct(Request $request, int $product_id)
|
||||
{
|
||||
// phpcs:enable
|
||||
$toolProduct = ToolProduct::firstOrNew([
|
||||
'product_id' => $product_id,
|
||||
]);
|
||||
|
|
@ -633,10 +789,13 @@ class ProductsController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* helper method to update additionnal product info
|
||||
* anifoodProduct
|
||||
* helper method to update anifoodProduct info
|
||||
*
|
||||
* @param Request $request
|
||||
* @param integer $product_id
|
||||
* @return void
|
||||
*/
|
||||
public function saveAnifoodProduct(Request $request, $product_id)
|
||||
public function saveAnifoodProduct(Request $request, int $product_id)
|
||||
{
|
||||
$anifoodProduct = AnifoodProduct::firstOrNew([
|
||||
'product_id' => $product_id,
|
||||
|
|
@ -648,10 +807,13 @@ class ProductsController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* helper method to update additionnal product info
|
||||
* garmentProduct
|
||||
* helper method to update garmentProduct info
|
||||
*
|
||||
* @param Request $request
|
||||
* @param integer $product_id
|
||||
* @return void
|
||||
*/
|
||||
public function saveGarmentProduct(Request $request, $product_id)
|
||||
public function saveGarmentProduct(Request $request, int $product_id)
|
||||
{
|
||||
$garmentProduct = GarmentProduct::firstOrNew([
|
||||
'product_id' => $product_id,
|
||||
|
|
@ -663,28 +825,14 @@ class ProductsController extends Controller
|
|||
$garmentProduct->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* product detail intended for Bo
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
// not in use
|
||||
}
|
||||
|
||||
/**
|
||||
* index des produits mis en avant
|
||||
*
|
||||
* @return * @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function starred()
|
||||
{
|
||||
$products = Product::where('star', 1)->paginate(10);
|
||||
return view('bo.products.starred', compact('products'));
|
||||
}
|
||||
|
||||
/**
|
||||
* working method to start the mapping of inco fields into foodproduct
|
||||
*/
|
||||
/*
|
||||
public function mapIncoFieldsToFoodProduct () {
|
||||
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ class PromotionsController extends Controller
|
|||
$existingProds = Product::all();
|
||||
$promotion = new Promotion();
|
||||
$selectedProds = $promotion->products;
|
||||
// $existingProds = $existingProds->diff($selectedProds);
|
||||
return view('bo.promotions.create', compact('discTypes', 'existingProds', 'selectedProds'));
|
||||
}
|
||||
|
||||
|
|
@ -63,29 +62,19 @@ class PromotionsController extends Controller
|
|||
$promotion->date_end = $date_end;
|
||||
$promotion->save();
|
||||
|
||||
// prise en charge de la liaison avec les produits
|
||||
// Prise en charge de la liaison avec les produits.
|
||||
$promotion->products()->sync($productIds);
|
||||
|
||||
return redirect()->route('bo.promotions.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(int $id)
|
||||
{
|
||||
$promotion = Promotion::findOrFail($id);
|
||||
$discTypes = DiscountType::all();
|
||||
|
|
@ -104,7 +93,7 @@ class PromotionsController extends Controller
|
|||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$promotion = Promotion::findOrFail($id);
|
||||
|
||||
|
|
@ -124,7 +113,7 @@ class PromotionsController extends Controller
|
|||
$promotion->date_end = $date_end;
|
||||
$promotion->save();
|
||||
|
||||
// prise en charge de la liaison avec les produits
|
||||
// Prise en charge de la liaison avec les produits.
|
||||
$promotion->products()->sync($productIds);
|
||||
|
||||
return redirect()->route('bo.promotions.edit', $promotion->id)->with('success', 'Modifications enregistrés !');
|
||||
|
|
@ -136,11 +125,11 @@ class PromotionsController extends Controller
|
|||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$p = Promotion::findOrFail($id);
|
||||
|
||||
// prise en charge de la liaison avec les produits
|
||||
// Prise en charge de la liaison avec les produits.
|
||||
$p->products()->detach();
|
||||
|
||||
$p->delete();
|
||||
|
|
|
|||
|
|
@ -11,17 +11,33 @@ use Illuminate\Support\Str;
|
|||
|
||||
class RangesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$ranges = Range::all();
|
||||
return view('bo.ranges.index', compact('ranges'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('bo.ranges.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$name = $request->name;
|
||||
|
|
@ -55,13 +71,26 @@ class RangesController extends Controller
|
|||
return redirect()->route('bo.ranges.index');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(int $id)
|
||||
{
|
||||
$range = Range::findOrFail($id);
|
||||
return view('bo.ranges.edit', compact('range'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$name = $request->name;
|
||||
$slug = Str::slug($name);
|
||||
|
|
@ -110,13 +139,20 @@ class RangesController extends Controller
|
|||
return redirect()->route('bo.ranges.edit', $range->id)->with('success', 'Modifications enregistrés !');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$range = Range::findOrFail($id);
|
||||
|
||||
$product = Product::where('range_id', $range->id)->count();
|
||||
if ($product !== 0) {
|
||||
return redirect()->back()->withErrors("Suppression impossible : \"" . $range->name . "\" contient encore des produits.");
|
||||
return redirect()->back()
|
||||
->withErrors("Suppression impossible : \"" . $range->name . "\" contient encore des produits.");
|
||||
}
|
||||
|
||||
if ($range->picture !== null) {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,15 @@ use Illuminate\Support\Facades\Config;
|
|||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Manage settings page
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
*/
|
||||
public function manage(Request $request)
|
||||
{
|
||||
|
||||
$settings = Setting::all();
|
||||
$settingsToPrint = [];
|
||||
foreach ($settings as $setting) {
|
||||
|
|
@ -22,14 +28,14 @@ class SettingsController extends Controller
|
|||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$input = $request->all();
|
||||
|
||||
// comparer les settingsToPrint (en base) avec les inputs (pour trouver un nouveau)
|
||||
// Comparer les settingsToPrint (en base) avec les inputs (pour trouver un nouveau).
|
||||
foreach ($input as $key => $value) {
|
||||
if (
|
||||
!isset($settingsToPrint[$key])
|
||||
&& $key != "_method"
|
||||
&& $key != "_token"
|
||||
) {
|
||||
// new setting
|
||||
// New setting.
|
||||
$setting = new Setting();
|
||||
$setting->key = $key;
|
||||
$setting->value = $value ?? 0;
|
||||
|
|
@ -37,21 +43,23 @@ class SettingsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($settings); $i++) {
|
||||
$looplimit = count($settings);
|
||||
for ($i = 0; $i < $looplimit; $i++) {
|
||||
if (is_array($request->input($settings[$i]->key))) {
|
||||
$settings[$i]->value = implode(',', $request->input($settings[$i]->key));
|
||||
} else {
|
||||
$settings[$i]->value = $request->input($settings[$i]->key) === null ? 0 : $request->input($settings[$i]->key);
|
||||
$settings[$i]->value = $request->input($settings[$i]->key) === null ? 0
|
||||
: $request->input($settings[$i]->key);
|
||||
}
|
||||
$settings[$i]->save();
|
||||
}
|
||||
|
||||
// store redirector to keep flash message from being wipe pby artisan call below
|
||||
// Store redirector to keep flash message from being wipe pby artisan call below.
|
||||
$redirector = redirect()->route('bo.settings')->with('success', 'Modifications enregistrés !');
|
||||
|
||||
// all settings saved : cache routes
|
||||
// All settings saved : cache routes.
|
||||
Artisan::call('route:clear');
|
||||
// programmer un php artisan optimize ? (une fois par jour la nuit par exemple)
|
||||
// Programmer un php artisan optimize ? (une fois par jour la nuit par exemple).
|
||||
return $redirector;
|
||||
}//end if
|
||||
|
||||
|
|
@ -59,7 +67,12 @@ class SettingsController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Manage Theme settings page
|
||||
* Management des settings dont la clé est préfixée theme_
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
*/
|
||||
public function manageTheme(Request $request)
|
||||
{
|
||||
|
|
@ -71,22 +84,24 @@ class SettingsController extends Controller
|
|||
|
||||
$config_settings = Config::get(('theme.bo_theme_settings'));
|
||||
|
||||
// check if, for each of the theme defined settings we have a database setting
|
||||
// Check if, for each of the theme defined settings we have a database setting.
|
||||
foreach ($config_settings as $onekey => $params) {
|
||||
if (!isset($settingsToPrint['theme_' . $onekey])) {
|
||||
$dbsetting = new Setting();
|
||||
$dbsetting->key = 'theme_' . $onekey;
|
||||
$dbsetting->value = $params['default_value'];
|
||||
$dbsetting->save();
|
||||
// injection dans settings to print
|
||||
// Injection dans settings to print.
|
||||
$settingsToPrint[$dbsetting->key] = $dbsetting->value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
for ($i = 0; $i < count($settings); $i++) {
|
||||
// attention pour les booléens/checkbox on enregistre 'on'
|
||||
$settings[$i]->value = $request->input($settings[$i]->key) === null ? 0 : $request->input($settings[$i]->key);
|
||||
$looplimit = count($settings);
|
||||
for ($i = 0; $i < $looplimit; $i++) {
|
||||
// Attention pour les booléens/checkbox on enregistre 'on'.
|
||||
$settings[$i]->value = $request->input($settings[$i]->key) === null ? 0
|
||||
: $request->input($settings[$i]->key);
|
||||
$settings[$i]->save();
|
||||
}
|
||||
return redirect()->route('bo.themesettings')->with('success', 'Modifications enregistrés !');
|
||||
|
|
|
|||
|
|
@ -59,23 +59,13 @@ class SlidersController extends Controller
|
|||
return redirect()->route('bo.sliders.edit', $slider->id)->with('success', 'Slider créé !');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(int $id)
|
||||
{
|
||||
$slider = Slider::findOrFail($id);
|
||||
return view('bo.sliders.edit', compact('slider'));
|
||||
|
|
@ -88,7 +78,7 @@ class SlidersController extends Controller
|
|||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$slider = Slider::findOrFail($id);
|
||||
$label = $request->label;
|
||||
|
|
@ -115,7 +105,7 @@ class SlidersController extends Controller
|
|||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$slider = Slider::findOrFail($id);
|
||||
|
||||
|
|
@ -124,7 +114,6 @@ class SlidersController extends Controller
|
|||
if ($count === 1) {
|
||||
return redirect()->back()->withErrors("Suppression impossible : Vous devez conserver au moins 1 Slider");
|
||||
}
|
||||
// @todo : controller les slides liés
|
||||
$slider->delete();
|
||||
return redirect()->route('bo.sliders.index');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ class SlidesController extends Controller
|
|||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @todo : validation des dates
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
|
@ -101,23 +99,13 @@ class SlidesController extends Controller
|
|||
return redirect()->route('bo.slides.edit', $slide->id)->with('success', 'Slide créé !');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(int $id)
|
||||
{
|
||||
$slide = Slide::findOrFail($id);
|
||||
$sliders = Slider::all();
|
||||
|
|
@ -131,7 +119,7 @@ class SlidesController extends Controller
|
|||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$title = $request->title;
|
||||
$picture = $request->picture;
|
||||
|
|
@ -200,7 +188,7 @@ class SlidesController extends Controller
|
|||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$s = Slide::findOrFail($id);
|
||||
|
||||
|
|
@ -209,8 +197,14 @@ class SlidesController extends Controller
|
|||
return redirect()->route('bo.slides.index');
|
||||
}
|
||||
|
||||
|
||||
public function changeOrder($id, $action)
|
||||
/**
|
||||
* Change Slide Order
|
||||
*
|
||||
* @param integer $id
|
||||
* @param string $action
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function changeOrder(int $id, string $action)
|
||||
{
|
||||
$current = Slide::findOrFail($id);
|
||||
|
||||
|
|
@ -229,11 +223,12 @@ class SlidesController extends Controller
|
|||
$current->save();
|
||||
|
||||
return back();
|
||||
// return redirect()->route('bo.slides.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* retreive order position to put a new slide to
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
private function getLastOrder()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,23 +56,13 @@ class TagsController extends Controller
|
|||
return redirect()->route('bo.tags.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(int $id)
|
||||
{
|
||||
$tag = Tag::findOrFail($id);
|
||||
return view('bo.tags.edit', compact('tag'));
|
||||
|
|
@ -85,7 +75,7 @@ class TagsController extends Controller
|
|||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$label = $request->label;
|
||||
$slug = Str::slug($label);
|
||||
|
|
@ -111,21 +101,28 @@ class TagsController extends Controller
|
|||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$tag = Tag::findOrFail($id);
|
||||
|
||||
$products = $tag->products()->count();
|
||||
if ($products !== 0) {
|
||||
return redirect()->back()->withErrors("Suppression impossible : \"" . $tag->label . "\" est associé à des produits.");
|
||||
return redirect()->back()
|
||||
->withErrors("Suppression impossible : \"" . $tag->label . "\" est associé à des produits.");
|
||||
}
|
||||
|
||||
$tag->delete();
|
||||
return redirect()->route('bo.tags.index');
|
||||
}
|
||||
|
||||
|
||||
public function changeOrder($id, $action)
|
||||
/**
|
||||
* Change Tag Order
|
||||
*
|
||||
* @param integer $id
|
||||
* @param string $action
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function changeOrder(int $id, string $action)
|
||||
{
|
||||
$current = Tag::findOrFail($id);
|
||||
|
||||
|
|
@ -144,10 +141,15 @@ class TagsController extends Controller
|
|||
$current->save();
|
||||
|
||||
return back();
|
||||
// return redirect()->route('bo.slides.index');
|
||||
}
|
||||
|
||||
public function toggleStatus($id)
|
||||
/**
|
||||
* Toggle tag status
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function toggleStatus(int $id)
|
||||
{
|
||||
$tag = Tag::findOrFail($id);
|
||||
$tag->status = !($tag->status);
|
||||
|
|
@ -158,6 +160,8 @@ class TagsController extends Controller
|
|||
|
||||
/**
|
||||
* retreive order position to put a new slide to
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function getLastOrder()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,8 +12,17 @@ use Illuminate\Http\Request;
|
|||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
/**
|
||||
* legal notice page
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function contact(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$status = $request->session()->get('status');
|
||||
|
||||
// 1er magasin en base pour le moment
|
||||
|
|
@ -23,6 +32,12 @@ class ContactController extends Controller
|
|||
return view('contact', compact('status', 'magasin', 'content'));
|
||||
}
|
||||
|
||||
/**
|
||||
* submit contact form
|
||||
*
|
||||
* @param ContactFormRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function contactSubmit(ContactFormRequest $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
|
|
@ -33,7 +48,7 @@ class ContactController extends Controller
|
|||
} else {
|
||||
$toMail = $toMailSetting->value;
|
||||
}
|
||||
// envoi du mail d'alerte
|
||||
// Envoi du mail d'alerte.
|
||||
Mail::to($toMail)->send(new SendContactMail($request));
|
||||
|
||||
return back()->with('status', true);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ class CustomerController extends Controller
|
|||
{
|
||||
/**
|
||||
* Affiche la page d'inscription
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function registerForm()
|
||||
{
|
||||
|
|
@ -120,6 +122,9 @@ class CustomerController extends Controller
|
|||
|
||||
/**
|
||||
* Retourne la page de connexion
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function authenticateForm(Request $request)
|
||||
{
|
||||
|
|
@ -212,6 +217,8 @@ class CustomerController extends Controller
|
|||
|
||||
/**
|
||||
* deconnexion customer
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
|
|
@ -223,14 +230,23 @@ class CustomerController extends Controller
|
|||
|
||||
/**
|
||||
* page d'accès à la procédure mdp oublié
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function forgotPasswordForm(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
return view('auth.passwords.forgot');
|
||||
}
|
||||
|
||||
/**
|
||||
* initialisation de la procédure de mdp oublié
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function passwordReset(Request $request)
|
||||
{
|
||||
|
|
@ -243,7 +259,7 @@ class CustomerController extends Controller
|
|||
$customerExist = Customers::where('email', $email)->count() === 0 ? false : true;
|
||||
|
||||
if ($customerExist) {
|
||||
// Suppression des anciens tokens
|
||||
// Suppression des anciens tokens.
|
||||
PasswordReset::where('email', $email)->delete();
|
||||
|
||||
$token = Str::random(80);
|
||||
|
|
@ -266,10 +282,10 @@ class CustomerController extends Controller
|
|||
|
||||
/**
|
||||
* Print the view used to change the password of a user when he required it
|
||||
* @param $token Token used to identificate the user to change the password of
|
||||
* @return View The view to print
|
||||
* @param string $token Token used to identificate the user to change the password.
|
||||
* @return \Illuminate\Contracts\View\View The view to print
|
||||
*/
|
||||
public function viewChangePassword($token)
|
||||
public function viewChangePassword(string $token)
|
||||
{
|
||||
$pwdReset = PasswordReset::where('token', $token)->first();
|
||||
if (!$pwdReset) {
|
||||
|
|
@ -335,11 +351,16 @@ class CustomerController extends Controller
|
|||
|
||||
/**
|
||||
* profil client (mon compte)
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function dashboard(Request $request)
|
||||
{
|
||||
|
||||
// show Profile
|
||||
// @phpcs:enable
|
||||
// Show Profile.
|
||||
/** @var \App\Models\Customers|null $customer */
|
||||
$customer = Auth::guard('customer')->user();
|
||||
if (!$customer) {
|
||||
|
|
@ -378,6 +399,9 @@ class CustomerController extends Controller
|
|||
|
||||
/**
|
||||
* changement de mot de passe depuis le profil
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function changePasswordWhenAuthenticated(Request $request)
|
||||
{
|
||||
|
|
@ -397,14 +421,26 @@ class CustomerController extends Controller
|
|||
|
||||
/**
|
||||
* affichage des commandes du customer connecté
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function myOrders(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$orders = Order::where('customer_id', Auth::guard('customer')->user()->id)->orderBy('date', 'DESC')->get();
|
||||
return view('customer.my-orders', compact('orders'));
|
||||
}
|
||||
|
||||
public function orderDetail($reference)
|
||||
/**
|
||||
* Show detail commande
|
||||
*
|
||||
* @param string $reference
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function orderDetail(string $reference)
|
||||
{
|
||||
$order = Order::where('reference', '=', $reference)
|
||||
->where('customer_id', Auth::guard('customer')->user()->id)
|
||||
|
|
@ -419,24 +455,16 @@ class CustomerController extends Controller
|
|||
return view('customer.order-detail', compact('order', 'magasin'));
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
/**
|
||||
* delete customers
|
||||
*
|
||||
* @param integer $id
|
||||
* @return void
|
||||
*/
|
||||
public function delete(int $id)
|
||||
{
|
||||
// TODO : Implémenter la suppression lorsque la CRM sera prête pour le faire aussi
|
||||
dump('deleting' . $id);
|
||||
die('Not implemented yet');
|
||||
// Suppression d'un compte client
|
||||
$customer = Customers::findOrFail($id);
|
||||
$customer->recipes()->delete();
|
||||
$customer->products()->delete();
|
||||
$customer->answers()->delete();
|
||||
$customer->forums()->delete();
|
||||
|
||||
// TODO : Suppression via la CRM
|
||||
if (Auth::guard('customer')->user()->id === $customer->id) {
|
||||
Auth::guard('customer')->logout();
|
||||
}
|
||||
$customer->delete();
|
||||
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -539,7 +567,6 @@ class CustomerController extends Controller
|
|||
return \redirect()->back();
|
||||
}
|
||||
|
||||
// TODO: Activer le changement d'email quand ce sera possible dans la CRM.
|
||||
/** @var \LDC\LDCCRM\Models\Customer */
|
||||
$crmCustomer = $customer->apiData;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,19 @@ use LDC\LDCCRM\Models\SingleOptin;
|
|||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display homepage
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$content = Content::where('key', 'accueil')->first();
|
||||
// star products
|
||||
// Star products.
|
||||
$products = Product::where('status', 1)->where('star', 1)->get();
|
||||
|
||||
$slider = Slider::where('slug', 'home')->first();
|
||||
|
|
@ -36,8 +45,10 @@ class HomeController extends Controller
|
|||
|
||||
/**
|
||||
* Call the CRM to add a single optin
|
||||
* @param string $email Email to add as a single optin
|
||||
* @return string Message to print to the customer
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
*/
|
||||
public function addOptIn(Request $request)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,34 +9,61 @@ use Illuminate\Http\Request;
|
|||
class IndexController extends Controller
|
||||
{
|
||||
/**
|
||||
* deprecated
|
||||
* legal notice page
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function contact(Request $request)
|
||||
{
|
||||
$content = Content::where('key', 'contact')->first();
|
||||
return view('contact', compact('content'));
|
||||
}
|
||||
|
||||
public function legalNotice(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$content = Content::where('key', 'legals')->first();
|
||||
return view('legal-notice', compact('content'));
|
||||
}
|
||||
|
||||
/**
|
||||
* terms and conditions page
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function terms(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$content = Content::where('key', 'cgv')->first();
|
||||
return view('terms', compact('content'));
|
||||
}
|
||||
|
||||
/**
|
||||
* privacy page
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function privacy(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$content = Content::where('key', 'confidentialite')->first();
|
||||
return view('privacy', compact('content'));
|
||||
}
|
||||
|
||||
/**
|
||||
* faq page
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function faq(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$content = Content::where('key', 'faq')->first();
|
||||
$faq = Faq::all();
|
||||
return view('faq', compact('faq', 'content'));
|
||||
|
|
|
|||
|
|
@ -10,43 +10,64 @@ use Illuminate\Http\Request;
|
|||
class ProductsController extends Controller
|
||||
{
|
||||
/**
|
||||
* page des gammes
|
||||
* Ranges page
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function ranges(Request $request)
|
||||
{
|
||||
// now in AppServiceProvider
|
||||
// $ranges = Range::all();
|
||||
// return view('ranges', compact('ranges'));
|
||||
// @phpcs:enable
|
||||
// $ranges shared in AppServiceProvider.
|
||||
return view('ranges');
|
||||
}
|
||||
|
||||
/**
|
||||
* page une gamme
|
||||
* One Range page
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $range_slug
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
*/
|
||||
public function range(Request $request, $range_slug)
|
||||
public function range(Request $request, string $range_slug)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$range = Range::where('slug', $range_slug)->first();
|
||||
if (!$range || !$range->status) {
|
||||
abort(404);
|
||||
}
|
||||
$products = Product::where('range_id', $range->id)->where('status', 1)->paginate(9);
|
||||
// find promo within range
|
||||
$offres = Product::where('range_id', $range->id)->where('status', 1)->has('promotions')->with('promotions')->get();
|
||||
// Find promo within range.
|
||||
$offres = Product::where('range_id', $range->id)
|
||||
->where('status', 1)
|
||||
->has('promotions')
|
||||
->with('promotions')->get();
|
||||
return view('range', compact('range', 'products', 'offres'));
|
||||
}
|
||||
|
||||
/**
|
||||
* page produit
|
||||
* One product page
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $product_slug
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
*/
|
||||
public function product(Request $request, $product_slug)
|
||||
public function product(Request $request, string $product_slug)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$product = Product::where('slug', $product_slug)->first();
|
||||
if (!$product || !$product->status) {
|
||||
abort(404);
|
||||
}
|
||||
$product->additionnalProductInfo = $product->additionnalProductInfo($product->product_type);
|
||||
if ($product->additionnalProductInfo === null && !empty($product_type)) {
|
||||
// n'existe pas on renseigne un vide
|
||||
// N'existe pas on renseigne un vide.
|
||||
$product_type = $product->product_type;
|
||||
$modelClass = 'App\Models\\' . ucfirst($product_type);
|
||||
$product->$product_type = new $modelClass();
|
||||
|
|
@ -60,6 +81,10 @@ class ProductsController extends Controller
|
|||
/**
|
||||
* tous les produits
|
||||
* recherche par nom de produit
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
*/
|
||||
public function allProducts(Request $request)
|
||||
{
|
||||
|
|
@ -80,10 +105,18 @@ class ProductsController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* produits filtrés par tag (1 tag)
|
||||
* tous les produits
|
||||
* filtrage par tag
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $tag_slug
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
*/
|
||||
public function tagFiltered(Request $request, $tag_slug)
|
||||
public function tagFiltered(Request $request, string $tag_slug)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$products = Product::where('status', 1)
|
||||
->whereHas('tags', function ($q) use ($tag_slug) {
|
||||
$q->where('slug', '=', $tag_slug);
|
||||
|
|
|
|||
|
|
@ -7,8 +7,17 @@ use Illuminate\Http\Request;
|
|||
|
||||
class QuickOrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* Quickorder page
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$quickorder_ranges = Range::with('products')->get();
|
||||
foreach ($quickorder_ranges as $range) {
|
||||
foreach ($range->products as $product) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Http\Middleware\isAdmin;
|
||||
use App\Http\Middleware\IsAdmin;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
|
|
@ -15,7 +15,6 @@ class Kernel extends HttpKernel
|
|||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
|
|
@ -34,7 +33,6 @@ class Kernel extends HttpKernel
|
|||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
|
|
@ -64,6 +62,6 @@ class Kernel extends HttpKernel
|
|||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'is-admin' => isAdmin::class,
|
||||
'is-admin' => IsAdmin::class,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class Authenticate extends Middleware
|
|||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param mixed $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class isAdmin
|
||||
class IsAdmin
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
|
|
@ -14,7 +15,7 @@ class isAdmin
|
|||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$role = Auth::user()->role;
|
||||
if ($role === 1 || $role === 2) {
|
||||
|
|
@ -6,6 +6,7 @@ use App\Models\OldSlug;
|
|||
use App\Models\Product;
|
||||
use App\Models\Range;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RedirectOldSlugs
|
||||
{
|
||||
|
|
@ -16,7 +17,7 @@ class RedirectOldSlugs
|
|||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$productSlug = $request->route('productSlug');
|
||||
$rangeSlug = $request->route('rangeSlug');
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ class ContactFormRequest extends FormRequest
|
|||
return [
|
||||
'last_name' => 'required|min:2',
|
||||
'first_name' => 'required|min:2',
|
||||
// TODO: The dns and spoof validators require the PHP intl extension. (présent sur prod ?)
|
||||
'email' => 'required|email:rfc,dns,spoof',
|
||||
'subject' => 'required|min:2',
|
||||
'order_ref' => 'sometimes',
|
||||
|
|
|
|||
|
|
@ -6,14 +6,18 @@ abstract class CsvJobs extends XArcadiaFlux
|
|||
{
|
||||
/**
|
||||
* parse csv file
|
||||
*
|
||||
* @param string $csvFile
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function parseCsv($csvFile)
|
||||
protected function parseCsv(string $csvFile)
|
||||
{
|
||||
$file_handle = fopen($csvFile, 'r');
|
||||
while (!feof($file_handle)) {
|
||||
$line_of_text[] = fgetcsv($file_handle, 0, ";");
|
||||
if (!end($line_of_text)) {
|
||||
// supprime les lignes vides du csv
|
||||
// Supprime les lignes vides du csv.
|
||||
array_pop($line_of_text);
|
||||
}
|
||||
}
|
||||
|
|
@ -36,10 +40,19 @@ abstract class CsvJobs extends XArcadiaFlux
|
|||
/**
|
||||
* converts an array to a csv stream
|
||||
*
|
||||
* @param array $data
|
||||
* @param string $delimiter
|
||||
* @param string $enclosure
|
||||
* @param string $escape_char
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function array2csv($data, $delimiter = ',', $enclosure = '"', $escape_char = "\\")
|
||||
{
|
||||
protected function array2csv(
|
||||
array $data,
|
||||
string $delimiter = ',',
|
||||
string $enclosure = '"',
|
||||
string $escape_char = "\\"
|
||||
) {
|
||||
$f = fopen('php://memory', 'r+');
|
||||
foreach ($data as $item) {
|
||||
fputcsv($f, $item, $delimiter, $enclosure, $escape_char);
|
||||
|
|
|
|||
|
|
@ -7,13 +7,24 @@ use App\Models\Order;
|
|||
|
||||
class CsvOrderWrite extends CsvJobs
|
||||
{
|
||||
/**
|
||||
* The Laravel disk name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $disk = 'orders';
|
||||
|
||||
/** @var Order */
|
||||
/**
|
||||
* The Order to be exported
|
||||
*
|
||||
* @var Order
|
||||
* */
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* en-têtes
|
||||
* CSV File headers
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $header = [
|
||||
"CodeArt",
|
||||
|
|
@ -30,6 +41,8 @@ class CsvOrderWrite extends CsvJobs
|
|||
|
||||
/**
|
||||
* correspondance unité d'appro/mode de commande
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $mode_commande = [
|
||||
"COLIS" => "UEA",
|
||||
|
|
@ -40,6 +53,8 @@ class CsvOrderWrite extends CsvJobs
|
|||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Order $order
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
|
|
@ -66,32 +81,30 @@ class CsvOrderWrite extends CsvJobs
|
|||
/** @var Timeslot */
|
||||
$timeslot = $this->order->timeslot;
|
||||
|
||||
// insertion de la ligne d'en-têtes
|
||||
// Insertion de la ligne d'en-têtes.
|
||||
$csvlines[] = $this->header;
|
||||
|
||||
foreach ($orderlines as $orderline) {
|
||||
$product = $orderline->product;
|
||||
|
||||
// COLIS, KGM, PCE (faut il introduire un nouveau champs type unité de commande).
|
||||
$unité_commande = $product->order_unit ?? 'PCE';
|
||||
// COLIS, KGM, PCE (faut il introduire un nouveau champs type unité de commande)
|
||||
// Matricule rh transmis sans les lettres de l'identifiant windows.
|
||||
$code_client = preg_replace('/[^\d]/', '', $customer->salarie->matricule);
|
||||
// matricule rh transmis sans les lettres de l'identifiant windows
|
||||
// convert to date object
|
||||
// Convert to date object.
|
||||
$datLivraison = Carbon::createFromFormat('d/m/Y H:i', $timeslot->day . " " . $timeslot->time);
|
||||
|
||||
$oneline = [
|
||||
$product->foodProduct->no_art,
|
||||
// 21/01/2022 : suppression du pcb ici
|
||||
// 21/01/2022 : suppression du pcb ici
|
||||
$code_client,
|
||||
$product->reference,
|
||||
"commande ferme",
|
||||
$unité_commande,
|
||||
// UEA,KGM,UB (respectivement selon le champ précédent).
|
||||
$this->mode_commande[$unité_commande],
|
||||
// UEA,KGM,UB (respectivement selon le champ précédent)
|
||||
// On vide la colonne pcb comme demandé.
|
||||
"",
|
||||
// on vide la colonne pcb comme demandé
|
||||
$datLivraison->format('d/m/Y'),
|
||||
// dd/mm/yyyy
|
||||
$orderline->quantity,
|
||||
$this->order->reference,
|
||||
];
|
||||
|
|
@ -101,11 +114,15 @@ class CsvOrderWrite extends CsvJobs
|
|||
|
||||
$data = $this->array2csv($csvlines, ";");
|
||||
|
||||
// $outputfilename = date("Ymd_His") . microtime(true) . ".csv";
|
||||
$outputfilename = "BTQ_" . $this->order->reference . "_" . $code_client . "_" . $customer->salarie->nom . "_" . $customer->salarie->prenom . "_" . str_pad($customer->salarie->code_societe, 3, "0", STR_PAD_LEFT) . ".csv";
|
||||
$outputfilename = "BTQ_" .
|
||||
$this->order->reference . "_" .
|
||||
$code_client . "_" .
|
||||
$customer->salarie->nom . "_" .
|
||||
$customer->salarie->prenom . "_" .
|
||||
str_pad($customer->salarie->code_societe, 3, "0", STR_PAD_LEFT) . ".csv";
|
||||
|
||||
$disk->put($outputfilename, $data);
|
||||
|
||||
// send this file by mail
|
||||
// Send this file by mail.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,15 @@ class CsvSalariesReader extends CsvJobs
|
|||
{
|
||||
/**
|
||||
* This is for Laravel Console usage
|
||||
* @var \Illuminate\Console\Command|null
|
||||
*/
|
||||
public $console = null;
|
||||
|
||||
/**
|
||||
* The Laravel disk name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $disk = 'salaries';
|
||||
|
||||
/**
|
||||
|
|
@ -60,7 +66,7 @@ class CsvSalariesReader extends CsvJobs
|
|||
|
||||
try {
|
||||
$data = $this->parseCsv($filepath);
|
||||
// first line is header (mandatory)
|
||||
// First line is header (mandatory).
|
||||
$header = array_flip(array_shift($data));
|
||||
foreach ($data as $line) {
|
||||
$matricule = $line[$header['matricule']];
|
||||
|
|
@ -88,7 +94,7 @@ class CsvSalariesReader extends CsvJobs
|
|||
LogType::critical()
|
||||
);
|
||||
continue;
|
||||
// ignore the file
|
||||
// Ignore the file.
|
||||
} catch (AbortCsvImportException $e) {
|
||||
$this->log(
|
||||
sprintf(
|
||||
|
|
@ -100,17 +106,19 @@ class CsvSalariesReader extends CsvJobs
|
|||
LogType::error()
|
||||
);
|
||||
continue;
|
||||
// ignore the file
|
||||
// Ignore the file.
|
||||
}//end try
|
||||
$this->moveToArchives($filename);
|
||||
}//end foreach
|
||||
|
||||
// Clear old archives
|
||||
// Clear old archives.
|
||||
$this->clearOldArchives();
|
||||
}
|
||||
|
||||
/**
|
||||
* Génère un code d'inscription
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function generateCode()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,23 +38,15 @@ class RefreshSiteMap implements ShouldQueue
|
|||
'/login',
|
||||
'/bo',
|
||||
'/activer',
|
||||
// '/deconnexion',
|
||||
'/reinitialiser-mdp',
|
||||
// '/le-club-des-gaulois/la-boutique',
|
||||
// '/password/confirm',
|
||||
// '/produit/from-menus',
|
||||
// '/cote-cuisine/sante-et-nutrition/menu-equilibre-j',
|
||||
// '/la-marque/tracabilite/search',
|
||||
// '/frame',
|
||||
// '/map',
|
||||
// Hack ignore laravel debug bar.
|
||||
'/_debugbar',
|
||||
// Hack ignore laravel debug bar
|
||||
// Ignore ignition route.
|
||||
'_ignition/health-check',
|
||||
// ignore ignition route
|
||||
// Ignore ignition route.
|
||||
'_ignition/scripts/{script}',
|
||||
// ignore ignition route
|
||||
// Ignore ignition route.
|
||||
'_ignition/styles/{style}'
|
||||
// ignore ignition route
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -77,13 +69,12 @@ class RefreshSiteMap implements ShouldQueue
|
|||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* ! Ici c'est du sale !!
|
||||
* TODO: mettre tout ça dans un package pour le rendre plus générique
|
||||
*
|
||||
* @return void
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// @phpcs:enable
|
||||
$this->assertRouteBinderIsCorrect();
|
||||
|
||||
$siteMap = [];
|
||||
|
|
@ -119,20 +110,20 @@ class RefreshSiteMap implements ShouldQueue
|
|||
/** @var string $pName $parameter name on route uri */
|
||||
$pName = '';
|
||||
|
||||
// If the route has parameters and the controller accepts it
|
||||
// If the route has parameters and the controller accepts it.
|
||||
if (count($pNames) and \array_key_exists($param->getPosition(), $pNames)) {
|
||||
// Get the controller parameter name for the route
|
||||
// Get the controller parameter name for the route.
|
||||
$pName = $pNames[$param->getPosition()];
|
||||
}
|
||||
|
||||
// If We have a custom binder for this route
|
||||
// If We have a custom binder for this route.
|
||||
if ($this->hasRouteBinderParam($route, $pName)) {
|
||||
$hasModels = true;
|
||||
$this->processWithRouteBinderParam($rParams, $route, $pName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If This route takes a model as param
|
||||
// If This route takes a model as param.
|
||||
if ($name and $name->isSubclassOf(Model::class)) {
|
||||
$hasModels = true;
|
||||
/** @var \string */
|
||||
|
|
@ -142,7 +133,7 @@ class RefreshSiteMap implements ShouldQueue
|
|||
}
|
||||
}//end foreach
|
||||
|
||||
// If the route has no dynamic models as parameters
|
||||
// If the route has no dynamic models as parameters.
|
||||
if (!count($params) or !$hasModels) {
|
||||
$siteMap[] = [
|
||||
route($route->getName()),
|
||||
|
|
@ -150,7 +141,7 @@ class RefreshSiteMap implements ShouldQueue
|
|||
0.1
|
||||
];
|
||||
} else {
|
||||
// If the route has dynamic models as parameters
|
||||
// If the route has dynamic models as parameters.
|
||||
$this->genRoute($route, $siteMap, $rParams);
|
||||
}
|
||||
}//end foreach
|
||||
|
|
@ -168,9 +159,11 @@ class RefreshSiteMap implements ShouldQueue
|
|||
/**
|
||||
* Process route with binderParam
|
||||
*
|
||||
* @param array $rParams
|
||||
* @param RoutingRoute $route
|
||||
* @param string $pName
|
||||
* @return void
|
||||
* @throws Exception When unhandled class.
|
||||
*/
|
||||
private function processWithRouteBinderParam(array &$rParams, RoutingRoute $route, string $pName)
|
||||
{
|
||||
|
|
@ -232,7 +225,6 @@ class RefreshSiteMap implements ShouldQueue
|
|||
$modelTable = (new ReflectionClass($modelClassName))->newInstanceWithoutConstructor()->getTable();
|
||||
$q = $modelClassName::query();
|
||||
$q = Schema::hasColumn($modelTable, 'status') ? $q->where('status', true) : $q;
|
||||
$q = Schema::hasColumn($modelTable, 'ocbStatus') ? $q->where('ocbStatus', EleveurOcbStatus::yes()->value) : $q;
|
||||
$q = Schema::hasColumn($modelTable, 'star_moment') ? $q->where('star_moment', true) : $q;
|
||||
do {
|
||||
$results = $q->offset($i * $limit)->limit($limit)->get();
|
||||
|
|
@ -332,7 +324,7 @@ class RefreshSiteMap implements ShouldQueue
|
|||
/**
|
||||
* Assert that routeBinder is correct
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws Exception When route does not exist | incomplrte parameters | parameter is not a model class.
|
||||
* @return void
|
||||
*/
|
||||
private function assertRouteBinderIsCorrect()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Jobs;
|
||||
|
||||
use App\Enums\LogType;
|
||||
use Exception;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
|
@ -30,6 +29,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
|
||||
/**
|
||||
* This is for Laravel Console usage
|
||||
* @var \Illuminate\Console\Command|null
|
||||
*/
|
||||
public $console = null;
|
||||
|
||||
|
|
@ -53,6 +53,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
* Check if the file extension
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $extension
|
||||
* @return boolean
|
||||
*/
|
||||
protected function checkExtension(string $filename, string $extension): bool
|
||||
|
|
@ -144,6 +145,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
* @param string $message
|
||||
* @param LogType $logtype
|
||||
* @return void
|
||||
* @throws \ErrorException If logtype is not handled.
|
||||
*/
|
||||
protected function log(string $message, LogType $logtype = null): void
|
||||
{
|
||||
|
|
@ -171,7 +173,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
Log::critical($message);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(sprintf('%s : unhandled log type %s', get_class($this), $logtype->label));
|
||||
throw new \ErrorException(sprintf('%s : unhandled log type %s', get_class($this), $logtype->label));
|
||||
}//end switch
|
||||
$this->consolePrint($message, $logtype);
|
||||
}
|
||||
|
|
@ -182,6 +184,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
* @param string $message
|
||||
* @param LogType $logtype
|
||||
* @return void
|
||||
* @throws \ErrorException If logtype is not handled.
|
||||
*/
|
||||
protected function consolePrint(string $message, LogType $logtype): void
|
||||
{
|
||||
|
|
@ -200,7 +203,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
$this->console->error($message);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(sprintf('%s : unhandled log type %s', get_class($this), $logtype->label));
|
||||
throw new \ErrorException(sprintf('%s : unhandled log type %s', get_class($this), $logtype->label));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,26 @@ use SimpleXMLElement;
|
|||
|
||||
class XmlIncoReader extends XmlJobs
|
||||
{
|
||||
/**
|
||||
* The Laravel disk name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $disk = 'inco';
|
||||
|
||||
/**
|
||||
* Storage path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $imagesPath = 'images';
|
||||
|
||||
/**
|
||||
* The columns to take from the XML
|
||||
* subcolumns can be added with a dot
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* éléments à la racine : nom du noeud
|
||||
* sous éléments d'un noeud PARENT :
|
||||
* d'abord:
|
||||
|
|
@ -29,8 +44,8 @@ class XmlIncoReader extends XmlJobs
|
|||
*/
|
||||
protected $takeColumns = [
|
||||
'NO_ART' => 'id',
|
||||
// primary key on model
|
||||
// this wil not return anything cf doc above
|
||||
// Primary key on model.
|
||||
// This wil not return anything cf doc above.
|
||||
'ID_SOCIETE' => 'id_societe',
|
||||
'NOM_SOCIETE' => 'nom_societe',
|
||||
|
||||
|
|
@ -51,19 +66,19 @@ class XmlIncoReader extends XmlJobs
|
|||
'LIB_CONSO' => 'lib_conso',
|
||||
'LST_ING' => 'lst_ing',
|
||||
// $ingredients
|
||||
// list alergene
|
||||
// List alergene.
|
||||
'LST_ALLERGENE' => 'lst_allergene',
|
||||
// Consider this sub array
|
||||
// Consider this sub array.
|
||||
'LST_ALLERGENE.LIB_ALLERGENE' => 'lib_allergene',
|
||||
|
||||
// Allegations
|
||||
// Allegations.
|
||||
'ALLEGAT_SANTE' => 'allegat_sante',
|
||||
'ALLEGAT_NUTRIT' => 'allegat_nutrit',
|
||||
'ALLEGAT_AUTRE' => 'allegat_autre',
|
||||
|
||||
|
||||
'INCO_COMPO' => 'inco_compo',
|
||||
// Consider this sub array
|
||||
// Consider this sub array.
|
||||
'INCO_COMPO.NOM' => 'nom',
|
||||
'INCO_COMPO.TAILLE_REF' => 'taille_ref',
|
||||
'INCO_COMPO.VAL_ENERG_KJ_NUT' => 'val_energ_kj_nut',
|
||||
|
|
@ -90,7 +105,7 @@ class XmlIncoReader extends XmlJobs
|
|||
'INCO_COMPO.FRUITS_R' => 'fruits_r',
|
||||
'INCO_COMPO.FRUITS_COQUE_SECH_R' => 'fruits_coque_sech_r',
|
||||
'INCO_COMPO.POURCENT_APPORT_REF_E14_R' => 'pourcent_apport_ref_e14_r',
|
||||
// POURCENT_*_P apports journaliers par portion
|
||||
// POURCENT_*_P apports journaliers par portion.
|
||||
'INCO_COMPO.ENER_KJO_R' => 'ener_kjo_r',
|
||||
'INCO_COMPO.POURCENT_APPORT_REF_KJO_R' => 'pourcent_apport_ref_kjo_r',
|
||||
'INCO_COMPO.POURCENT_APPORT_REF_FAT_R' => 'pourcent_apport_ref_fat_r',
|
||||
|
|
@ -153,9 +168,9 @@ class XmlIncoReader extends XmlJobs
|
|||
'INCO_COMPO.COMPOSANTE_P' => 'composante_p',
|
||||
'INCO_COMPO.POURCENT_FRUITS' => 'pourcent_fruits',
|
||||
'INCO_COMPO.SCORE_NUTRI' => 'score_nutri',
|
||||
// du coup nutriscore ?
|
||||
// Du coup nutriscore ?.
|
||||
'INCO_COMPO.CLASSEMENT' => 'classement',
|
||||
// $nutriscore mais pas censé être dans INCO_COMPO
|
||||
// $nutriscore mais pas censé être dans INCO_COMPO
|
||||
'INCO_COMPO.MAT_GRASS_R_PREC' => 'mat_grass_r_prec',
|
||||
'INCO_COMPO.AGS_R_PREC' => 'ags_r_prec',
|
||||
'INCO_COMPO.GLUCIDES_R_PREC' => 'glucides_r_prec',
|
||||
|
|
@ -168,6 +183,11 @@ class XmlIncoReader extends XmlJobs
|
|||
'INCO_COMPO.FRUITS_COQUE_SECH_R_PREC' => 'fruits_coque_sech_r_prec',
|
||||
];
|
||||
|
||||
/**
|
||||
* The columns allowed to be null
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $nullableFields = [
|
||||
'taille_ref',
|
||||
'conseil_prepa',
|
||||
|
|
@ -281,8 +301,18 @@ class XmlIncoReader extends XmlJobs
|
|||
'inco_compo.fruits_coque_sech_r_prec'
|
||||
];
|
||||
|
||||
/**
|
||||
* Unique keys for updating rows
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $uniqueKeyField = ['id'];
|
||||
|
||||
/**
|
||||
* Columns to merge in
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $mergeColumns = [
|
||||
'allegations' => [
|
||||
'allegat_sante',
|
||||
|
|
@ -388,15 +418,20 @@ class XmlIncoReader extends XmlJobs
|
|||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$this->parseData('INCO', XmlInco::class, function (SimpleXMLElement $xmlData, array &$line) {
|
||||
|
||||
// merge columns
|
||||
// Merge columns.
|
||||
foreach ($this->mergeColumns as $key => $values) {
|
||||
$line[$key] = [];
|
||||
// merge columns and remove merged columns from line
|
||||
// Merge columns and remove merged columns from line.
|
||||
array_map(function ($kValue) use (&$line, $key) {
|
||||
if (array_key_exists($kValue, $line)) {
|
||||
$line[$key][$kValue] = $line[$kValue];
|
||||
|
|
@ -407,13 +442,9 @@ class XmlIncoReader extends XmlJobs
|
|||
$line[$key] = implode(',', array_filter($line[$key]));
|
||||
$line[$key] = strlen($line[$key]) ? $line[$key] : null;
|
||||
}
|
||||
// json column cast into array in model => no need for encode
|
||||
// if ($key == 'nutritional_values') {
|
||||
// $line[$key] = json_encode($line[$key], \JSON_FORCE_OBJECT);
|
||||
// }
|
||||
}
|
||||
|
||||
// Boolean cast prod_saison
|
||||
// Boolean cast prod_saison.
|
||||
$line['prod_saison'] = isset($line['prod_saison']) ?
|
||||
(strtolower($line['prod_saison']) == 'non' ? false : true) : false;
|
||||
|
||||
|
|
@ -422,6 +453,13 @@ class XmlIncoReader extends XmlJobs
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Image form XML file
|
||||
*
|
||||
* @param SimpleXMLElement $xmlData
|
||||
* @return array
|
||||
* @throws AbortXmlImportException When media tag does not contain an image.
|
||||
*/
|
||||
private function parseImage(SimpleXMLElement $xmlData)
|
||||
{
|
||||
$list_media = $xmlData->INCO->MEDIA_VISUEL_EAI->MEDIA_VISUEL_EAI;
|
||||
|
|
@ -467,8 +505,6 @@ class XmlIncoReader extends XmlJobs
|
|||
|
||||
$arImgPaths[$index] = sprintf('%s/%s', $this->disk, $imgNamePath);
|
||||
$index++;
|
||||
} else {
|
||||
// probably not an image could be a PDF, PPT, AI anything is possible
|
||||
}//end if
|
||||
}//end if
|
||||
}//end foreach
|
||||
|
|
@ -520,7 +556,6 @@ class XmlIncoReader extends XmlJobs
|
|||
}
|
||||
|
||||
$extract[$key][] = $extraction;
|
||||
// $this->extract($value);
|
||||
continue;
|
||||
}
|
||||
$value = strval($value);
|
||||
|
|
|
|||
|
|
@ -52,13 +52,17 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
/**
|
||||
* Parse Data from the XML and gives it to the callback
|
||||
*
|
||||
* @param string $entityName
|
||||
* @param string $modelClass
|
||||
* @param string $entityName
|
||||
* @param string $modelClass
|
||||
* @param callable $callback
|
||||
* @throws InvalidXmlException When xml is invalid.
|
||||
* @return void
|
||||
*
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
*/
|
||||
// phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
protected function parseData(string $entityName, string $modelClass, callable $callback = null): void
|
||||
{
|
||||
// @phpcs:enable
|
||||
/** @var Filesystem */
|
||||
$disk = $this->getDisk();
|
||||
$this->log('Démarrage du traitement');
|
||||
|
|
@ -94,11 +98,6 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
|
||||
if ($xmlContent === false) {
|
||||
throw new InvalidXmlException('XML is Invalid (simplexml_load_string returned false)');
|
||||
// $this->log(
|
||||
// sprintf('File %s could not be parsed (simplexml_load_string)', $filename),
|
||||
// LogType::critical()
|
||||
// );
|
||||
// continue; // ignore the file
|
||||
}
|
||||
} catch (ErrorException $e) {
|
||||
throw new InvalidXmlException('XML is Invalid', 0, $e);
|
||||
|
|
@ -115,7 +114,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$lines[] = $line;
|
||||
}
|
||||
|
||||
// Mise en base des données
|
||||
// Mise en base des données.
|
||||
foreach ($lines as $line) {
|
||||
/** @var array Unique Key columns */
|
||||
$uniqueColumnsKey = [];
|
||||
|
|
@ -126,7 +125,6 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
[$modelClass, 'updateOrCreate'],
|
||||
[$uniqueColumnsKey, $line]
|
||||
);
|
||||
// @todo : should we put that method in a interface ?
|
||||
$savedData->updateLocalProductInfo();
|
||||
}
|
||||
} catch (InvalidXmlException $e) {
|
||||
|
|
@ -158,7 +156,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
);
|
||||
$this->sendErrorParseEmailToServiceWeb($e);
|
||||
continue;
|
||||
// ignore the file
|
||||
// Ignore the file.
|
||||
} catch (AbortXmlImportException $e) {
|
||||
$this->log(
|
||||
sprintf(
|
||||
|
|
@ -172,9 +170,9 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$this->sendErrorParseEmailToServiceWeb($e);
|
||||
$this->moveToInvalid($filename);
|
||||
continue;
|
||||
// ignore the file
|
||||
// Ignore the file.
|
||||
} catch (FileNotFoundException | QueryException $e) {
|
||||
// This happens because of concurent xml jobs read
|
||||
// This happens because of concurent xml jobs read.
|
||||
$message = $e->getMessage();
|
||||
if (get_class($e) === QueryException::class) {
|
||||
$message = implode(' ', $e->errorInfo);
|
||||
|
|
@ -189,12 +187,12 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
LogType::debug()
|
||||
);
|
||||
continue;
|
||||
// ignore the file
|
||||
// Ignore the file.
|
||||
}//end try
|
||||
$this->moveToArchives($filename);
|
||||
}//end foreach
|
||||
|
||||
// Clear old archives
|
||||
// Clear old archives.
|
||||
$this->clearOldArchives();
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +228,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
*
|
||||
* @param array $fields
|
||||
* @return array
|
||||
* @throws AbortXmlImportException
|
||||
* @throws AbortXmlImportException When field should not be null.
|
||||
*/
|
||||
protected function processFields(array $fields): array
|
||||
{
|
||||
|
|
@ -243,7 +241,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
throw new AbortXmlImportException(sprintf('The field %s is not allowed to be null', $key));
|
||||
}
|
||||
if (is_array($field)) {
|
||||
// Flatten data
|
||||
// Flatten data.
|
||||
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($field));
|
||||
foreach ($it as $k => $f) {
|
||||
$ko = strtolower(sprintf('%s.%s', $key, $k));
|
||||
|
|
@ -325,6 +323,12 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
return $isXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Error Mail
|
||||
*
|
||||
* @param Throwable $e
|
||||
* @return void
|
||||
*/
|
||||
protected function sendErrorParseEmailToServiceWeb(Throwable $e)
|
||||
{
|
||||
Mail::send('emails.exception', [
|
||||
|
|
@ -338,6 +342,13 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Mail Invalid XML
|
||||
*
|
||||
* @param string $filename
|
||||
* @param Throwable $e
|
||||
* @return void
|
||||
*/
|
||||
protected function sendInvalidXmlEmail(string $filename, Throwable $e)
|
||||
{
|
||||
$message = $e->getPrevious()->getMessage();
|
||||
|
|
|
|||
|
|
@ -7,8 +7,17 @@ use Gloudemans\Shoppingcart\Contracts\Calculator;
|
|||
|
||||
class CartCalculator implements Calculator
|
||||
{
|
||||
/**
|
||||
* All purpose getter
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param CartItem $cartItem
|
||||
* @return float|void
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
*/
|
||||
public static function getAttribute(string $attribute, CartItem $cartItem)
|
||||
{
|
||||
// @phpcs:enable
|
||||
$decimals = config('cart.format.decimals', 2);
|
||||
|
||||
switch ($attribute) {
|
||||
|
|
@ -27,11 +36,10 @@ class CartCalculator implements Calculator
|
|||
case 'priceTarget':
|
||||
return round(($cartItem->priceTotal - $cartItem->discountTotal) / $cartItem->qty, $decimals);
|
||||
case 'taxTotal':
|
||||
// taxe pour un item multiplié par la quantité
|
||||
// Taxe pour un item multiplié par la quantité.
|
||||
$unit_price = max($cartItem->price - $cartItem->discount, 0);
|
||||
$unit_tax = round($unit_price * ($cartItem->taxRate / 100), $decimals);
|
||||
$taxTotal = round($unit_tax * $cartItem->qty, $decimals);
|
||||
// return round($cartItem->subtotal * ($cartItem->taxRate / 100), $decimals);
|
||||
return $taxTotal;
|
||||
case 'total':
|
||||
return round($cartItem->subtotal + $cartItem->taxTotal, $decimals);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Mail;
|
||||
|
||||
use App\Models\Magasin;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
|
@ -12,14 +13,21 @@ class OrderConfirmAdminMail extends Mailable
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Order
|
||||
*
|
||||
* @var \App\Models\Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param \App\Models\Order $order
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($order)
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
|
@ -34,6 +42,8 @@ class OrderConfirmAdminMail extends Mailable
|
|||
$order = $this->order;
|
||||
$magasin = Magasin::find($order->timeslot->magasin->id);
|
||||
|
||||
return $this->subject("Nouvelle Commande - " . config('theme.site_name'))->view('emails.order-confirm-admin', compact('order', 'magasin'));
|
||||
return $this->subject(
|
||||
"Nouvelle Commande - " . config('theme.site_name')
|
||||
)->view('emails.order-confirm-admin', compact('order', 'magasin'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Mail;
|
||||
|
||||
use App\Models\Magasin;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
|
@ -12,14 +13,21 @@ class OrderConfirmMail extends Mailable
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Order
|
||||
*
|
||||
* @var \App\Models\Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param \App\Models\Order $order
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($order)
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
|
@ -34,6 +42,8 @@ class OrderConfirmMail extends Mailable
|
|||
$order = $this->order;
|
||||
$magasin = Magasin::find($order->timeslot->magasin->id);
|
||||
|
||||
return $this->subject("Votre commande - " . config('theme.site_name'))->view('mails.order-confirm', compact('order', 'magasin'));
|
||||
return $this->subject(
|
||||
"Votre commande - " . config('theme.site_name')
|
||||
)->view('mails.order-confirm', compact('order', 'magasin'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Mail;
|
||||
|
||||
use App\Models\Magasin;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
|
@ -12,14 +13,20 @@ class OrderStatusMail extends Mailable
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Order
|
||||
*
|
||||
* @var \App\Models\Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param \App\Models\Order $order
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($order)
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
|
@ -34,6 +41,8 @@ class OrderStatusMail extends Mailable
|
|||
$order = $this->order;
|
||||
$magasin = Magasin::find($order->timeslot->magasin->id);
|
||||
|
||||
return $this->subject("Votre commande - " . config('theme.site_name'))->view('mails.order-status', compact('order', 'magasin'));
|
||||
return $this->subject(
|
||||
"Votre commande - " . config('theme.site_name')
|
||||
)->view('mails.order-status', compact('order', 'magasin'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,20 @@ class PasswordResetMail extends Mailable implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* Reset token
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $token;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($token)
|
||||
public function __construct(string $token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
|
@ -32,6 +38,8 @@ class PasswordResetMail extends Mailable implements ShouldQueue
|
|||
public function build()
|
||||
{
|
||||
$token = $this->token;
|
||||
return $this->subject("Réinitialiser votre accès - " . config('theme.site_name'))->view('mails.password-reset', compact('token'));
|
||||
return $this->subject(
|
||||
"Réinitialiser votre accès - " . config('theme.site_name')
|
||||
)->view('mails.password-reset', compact('token'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Customers;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
|
|
@ -12,14 +13,28 @@ class RegisterConfirmMail extends Mailable implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $customer, $firstname;
|
||||
/**
|
||||
* target Customer
|
||||
*
|
||||
* @var \App\Models\Customers
|
||||
*/
|
||||
private $customer;
|
||||
|
||||
/**
|
||||
* Customer's firstname
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $firstname;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param \App\Models\Customers $customer
|
||||
* @param string|null $firstname
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($customer, $firstname)
|
||||
public function __construct(Customers $customer, mixed $firstname)
|
||||
{
|
||||
$this->firstname = $firstname;
|
||||
$this->customer = $customer;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Http\Requests\ContactFormRequest;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
|
@ -14,6 +15,7 @@ class SendContactMail extends Mailable
|
|||
/**
|
||||
* The form data.
|
||||
*
|
||||
* @var \App\Http\Requests\ContactFormRequest
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
|
|
@ -28,9 +30,10 @@ class SendContactMail extends Mailable
|
|||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param \App\Http\Requests\ContactFormRequest $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
public function __construct(ContactFormRequest $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ class CollecteException extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['date', 'comment', 'magasin_id'];
|
||||
|
||||
/**
|
||||
|
|
@ -21,11 +26,22 @@ class CollecteException extends Model
|
|||
'date' => 'date',
|
||||
];
|
||||
|
||||
/**
|
||||
* Format a date
|
||||
*
|
||||
* @param DateTimeInterface $date
|
||||
* @return string
|
||||
*/
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* BelongsTo magasin relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function magasin()
|
||||
{
|
||||
return $this->belongsTo(Magasin::class);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,11 @@ class Customers extends Authenticatable
|
|||
protected $guard = 'customer';
|
||||
|
||||
|
||||
// possible additionnals
|
||||
/**
|
||||
* hasOne salarie relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function salarie()
|
||||
{
|
||||
return $this->hasOne(Salarie::class, 'customer_id');
|
||||
|
|
|
|||
|
|
@ -9,8 +9,18 @@ class DiscountType extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* hasMany promotions relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function promotions()
|
||||
{
|
||||
return $this->hasMany(Promotion::class, 'discount_type_id');
|
||||
|
|
|
|||
|
|
@ -9,5 +9,10 @@ class Faq extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['question', 'answer'];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,21 @@ class FoodProduct extends Model
|
|||
'product_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* BelongsTo product relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* hasOne product relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function xmlInco()
|
||||
{
|
||||
return $this->hasOne(XmlInco::class, 'id', 'no_art');
|
||||
|
|
|
|||
|
|
@ -9,22 +9,42 @@ class Magasin extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'address', 'postcode', 'city', 'phone',
|
||||
'latitude', 'longitude',
|
||||
'gmaps_placeid', 'gmaps_embed_href', 'gmaps_link_href',
|
||||
];
|
||||
|
||||
/**
|
||||
* hasMany timeslot settings relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function timeslotSettings()
|
||||
{
|
||||
return $this->hasMany(TimeslotSetting::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* hasMany collecte exceptions relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function collecteExceptions()
|
||||
{
|
||||
return $this->hasMany(CollecteException::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* hasMany timeslots relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function timeslots()
|
||||
{
|
||||
return $this->hasMany(Timeslot::class);
|
||||
|
|
|
|||
|
|
@ -9,11 +9,21 @@ class OldSlug extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* BelongsTo product relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo('App\Model\Product', 'product_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* BelongsTo range relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function range()
|
||||
{
|
||||
return $this->belongsTo('App\Model\Range', 'range_id');
|
||||
|
|
|
|||
|
|
@ -10,37 +10,66 @@ class Order extends Model
|
|||
use HasFactory;
|
||||
|
||||
/**
|
||||
* use carefully
|
||||
* BelongsToMany products relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'order_lines', 'order_id', 'product_id');
|
||||
}
|
||||
|
||||
// Relations
|
||||
/**
|
||||
* hasMany lines relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function lines()
|
||||
{
|
||||
return $this->hasMany(OrderLine::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* BelongsTo order_status relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
return $this->belongsTo('App\Models\OrdersStatus', 'status_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* BelongsTo customer relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customers::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* hasOne timeslot relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function timeslot()
|
||||
{
|
||||
return $this->hasOne(Timeslot::class);
|
||||
}
|
||||
|
||||
// Formattages
|
||||
/**
|
||||
* Custom Attribute
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormattedTotalTtcAttribute()
|
||||
{
|
||||
return $this->attributes['formattedTotalTtc'] = sprintf('%s €', number_format($this->attributes['total'], 2, ',', ' '));
|
||||
$this->attributes['formattedTotalTtc'] = sprintf(
|
||||
'%s €',
|
||||
number_format($this->attributes['total'], 2, ',', ' ')
|
||||
);
|
||||
return $this->attributes['formattedTotalTtc'];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,20 +9,37 @@ class OrderLine extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
// Relations
|
||||
/**
|
||||
* BelongsTo order relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* BelongsTo product relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
// Formattages
|
||||
/**
|
||||
* Getter for formattedTotalTtc
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function getFormattedTotalTtcAttribute()
|
||||
{
|
||||
return $this->attributes['formattedTotalTtc'] = sprintf('%s €', number_format($this->attributes['total_ttc'], 2, ',', ' '));
|
||||
$this->attributes['formattedTotalTtc'] = sprintf(
|
||||
'%s €',
|
||||
number_format($this->attributes['total_ttc'], 2, ',', ' ')
|
||||
);
|
||||
return $this->attributes['formattedTotalTtc'];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,25 @@ class OrdersStatus extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The table associated with the model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = "orders_status";
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* hasMany orders relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function orders()
|
||||
{
|
||||
return $this->hasMany('App\Models\Order', 'status_id');
|
||||
|
|
|
|||
|
|
@ -6,7 +6,17 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class PasswordReset extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = "password_resets";
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@ use Gloudemans\Shoppingcart\Contracts\Buyable;
|
|||
use Gloudemans\Shoppingcart\CanBeBought;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
/**
|
||||
* @todo : unité de vente/unité de poids devrait être des énums (via table liée ou package enum)
|
||||
*/
|
||||
class Product extends Model implements Buyable
|
||||
{
|
||||
use HasFactory;
|
||||
|
|
@ -36,26 +33,59 @@ class Product extends Model implements Buyable
|
|||
* Store in protected variables instead of attributes
|
||||
* Because those are not set in attributes, Laravel will not try to save it to database
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base Price
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $priceHt;
|
||||
|
||||
/**
|
||||
* Base Price after discount
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $discountedPriceHt;
|
||||
|
||||
/**
|
||||
* Price VAT included
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $priceTtc;
|
||||
|
||||
/**
|
||||
* Price after discount VAT included
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $discountedPriceTtc;
|
||||
|
||||
/**
|
||||
* Discount amount
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $discountAmount;
|
||||
|
||||
/**
|
||||
* Dsicount rate
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $discountRate;
|
||||
|
||||
/**
|
||||
* init prices on boot
|
||||
* Bootstrap the model and its traits.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
// on data retrived from DB
|
||||
// On data retrived from DB.
|
||||
static::retrieved(function ($model) {
|
||||
$model->priceHt = $model->getPriceHtAttribute();
|
||||
$model->priceTtc = $model->getPriceTtcAttribute();
|
||||
|
|
@ -75,10 +105,13 @@ class Product extends Model implements Buyable
|
|||
* net discounted proice (prix avec taxe et remises)
|
||||
*/
|
||||
|
||||
// Utility to bring prices as a pseudo relation
|
||||
/**
|
||||
* Utility to bring prices as a pseudo relation
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCalcPrices()
|
||||
{
|
||||
// $prices = new Collection();
|
||||
$prices = array(
|
||||
'priceHt' => $this->priceHt,
|
||||
'discountAmount' => $this->discountAmount,
|
||||
|
|
@ -87,15 +120,16 @@ class Product extends Model implements Buyable
|
|||
'priceTtc' => $this->priceTtc,
|
||||
'discountedPriceTtc' => $this->discountedPriceTtc,
|
||||
);
|
||||
// $prices->add($cartextendedItem);
|
||||
return $prices;
|
||||
}
|
||||
|
||||
// gross price
|
||||
/**
|
||||
* Mutator method to set priceHt's value
|
||||
* Mutator method to set priceHt's value gross price
|
||||
*
|
||||
* @param float $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPriceHtAttribute($value)
|
||||
public function setPriceHtAttribute(float $value)
|
||||
{
|
||||
$this->priceHt = $value;
|
||||
}
|
||||
|
|
@ -105,88 +139,130 @@ class Product extends Model implements Buyable
|
|||
* Accessor method for priceHt
|
||||
*
|
||||
* @author Olivier Legat <olivier.legat@ldc.fr>
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getPriceHtAttribute()
|
||||
{
|
||||
if (isset($this->priceHt)) {
|
||||
return $this->priceHt;
|
||||
} else {
|
||||
// tenir compte de l'unité de facturation et de l'unité de vente (qui doit être stricte)
|
||||
// si facturation KG et vente piece
|
||||
// prendre le poids, convertir en KG => pre-requis l'unité de poids doit être un enum
|
||||
// multiplier le $this->attributes['price'] par les KG
|
||||
// sinon
|
||||
// value => value
|
||||
/** Tenir compte de l'unité de facturation et de l'unité de vente (qui doit être stricte)
|
||||
* si facturation KG et vente piece
|
||||
* prendre le poids, convertir en KG => pre-requis l'unité de poids doit être un enum
|
||||
* multiplier le $this->attributes['price'] par les KG
|
||||
* sinon
|
||||
* value => value
|
||||
*/
|
||||
if (config('bosettings.sell_unit_management') == "strict") {
|
||||
$calculate = ($this->invoicing_unit == InvoicingUnit::kgm()->value && $this->sell_unit == SellUnit::pce()->value);
|
||||
$calculate = ($this->invoicing_unit == InvoicingUnit::kgm()->value
|
||||
&& $this->sell_unit == SellUnit::pce()->value);
|
||||
} else {
|
||||
$calculate = false;
|
||||
}
|
||||
|
||||
if ($calculate) {
|
||||
// weight converter
|
||||
$weighted_price = $this->attributes['price'] * ($this->weight * WeightUnit::convert()[$this->weight_unit]);
|
||||
return $this->priceHt = round($weighted_price * 1000) / 1000;
|
||||
// Weight converter.
|
||||
$weighted_price = $this->attributes['price']
|
||||
* ($this->weight * WeightUnit::convert()[$this->weight_unit]);
|
||||
$this->priceHt = round($weighted_price * 1000) / 1000;
|
||||
return $this->priceHt;
|
||||
} else {
|
||||
// no calculations, alias of db property
|
||||
return $this->priceHt = $this->attributes['price'];
|
||||
// No calculations, alias of db property.
|
||||
$this->priceHt = $this->attributes['price'];
|
||||
return $this->priceHt;
|
||||
}
|
||||
}//end if
|
||||
}
|
||||
|
||||
// discounted price
|
||||
public function setDiscountedPriceHtAttribute($value)
|
||||
/**
|
||||
* setter for dicounted price
|
||||
*
|
||||
* @param float $value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountedPriceHtAttribute(float $value)
|
||||
{
|
||||
$this->discountedPriceHt = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for discounted price
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscountedPriceHtAttribute()
|
||||
{
|
||||
if (isset($this->discountedPriceHt)) {
|
||||
return $this->discountedPriceHt;
|
||||
} else {
|
||||
$discountedPriceHt = $this->priceHt - $this->discountAmount;
|
||||
$roundingdiscountedPriceHt = round($discountedPriceHt * 1000) / 1000;
|
||||
return $this->discountedPriceHt = $roundingdiscountedPriceHt;
|
||||
$discountedPriceHt = $this->priceHt - $this->discountAmount;
|
||||
$roundingdiscountedPriceHt = round($discountedPriceHt * 1000) / 1000;
|
||||
$this->discountedPriceHt = $roundingdiscountedPriceHt;
|
||||
return $this->discountedPriceHt;
|
||||
}
|
||||
}
|
||||
|
||||
// net price
|
||||
public function setPriceTtcAttribute($value)
|
||||
/**
|
||||
* setter for net price
|
||||
*
|
||||
* @param float $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPriceTtcAttribute(float $value)
|
||||
{
|
||||
$this->priceTtc = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for net price
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getPriceTtcAttribute()
|
||||
{
|
||||
if (isset($this->priceTtc)) {
|
||||
return $this->priceTtc;
|
||||
} else {
|
||||
$priceTtc = $this->priceHt * ( 1 + ( $this->tax->rate / 100));
|
||||
// on travaille avec des centimes puis on redivise par 100 pour avoir des unités monetaires
|
||||
// on augmente la précision à 3 digits, l'affichage formate les prix sur 2 décimales
|
||||
$roundingPriceTtc = round($priceTtc * 1000) / 1000;
|
||||
return $this->priceTtc = $roundingPriceTtc;
|
||||
/**
|
||||
* On travaille avec des centimes puis on redivise par 100 pour avoir des unités monetaires
|
||||
* on augmente la précision à 3 digits, l'affichage formate les prix sur 2 décimales
|
||||
*/
|
||||
$roundingPriceTtc = round($priceTtc * 1000) / 1000;
|
||||
$this->priceTtc = $roundingPriceTtc;
|
||||
return $this->priceTtc;
|
||||
}
|
||||
}
|
||||
|
||||
// net discounted price
|
||||
public function setDiscountedPriceTtcAttribute($value)
|
||||
/**
|
||||
* setter for net dscounted price
|
||||
*
|
||||
* @param float $value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountedPriceTtcAttribute(float $value)
|
||||
{
|
||||
$this->discountedPriceTtc = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for net dscounted price
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscountedPriceTtcAttribute()
|
||||
{
|
||||
if (isset($this->discountedPriceTtc)) {
|
||||
$showPrice = $this->discountedPriceTtc;
|
||||
} else {
|
||||
$discountedPriceTtc = $this->discountedPriceHt * ( 1 + ( $this->tax->rate / 100));
|
||||
// on travaille avec des centimes puis on redivise par 100 pour avoir des unités monetaires
|
||||
// On travaille avec des centimes puis on redivise par 100 pour avoir des unités monetaires.
|
||||
$roundingDiscountedPriceTTC = round($discountedPriceTtc * 1000) / 1000;
|
||||
$showPrice = $this->discountedPriceTtc = $roundingDiscountedPriceTTC;
|
||||
$this->discountedPriceTtc = $roundingDiscountedPriceTTC;
|
||||
$showPrice = $this->discountedPriceTtc;
|
||||
}
|
||||
// prix transmis en fonction du setting show_prices
|
||||
// Prix transmis en fonction du setting show_prices.
|
||||
if (config('bosettings.show_prices_authenticated') == "authenticated") {
|
||||
{
|
||||
if (Auth::guard('customer')->check()) {
|
||||
|
|
@ -201,15 +277,25 @@ class Product extends Model implements Buyable
|
|||
}
|
||||
|
||||
/**
|
||||
* Discount calc
|
||||
* Discount calculators
|
||||
*/
|
||||
|
||||
// montant de remise
|
||||
public function setDiscountAmountAttribute($value)
|
||||
/**
|
||||
* set discoutn amount
|
||||
*
|
||||
* @param float $value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountAmountAttribute(float $value)
|
||||
{
|
||||
$this->discountAmount = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for discount amount
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscountAmountAttribute()
|
||||
{
|
||||
if (isset($this->discountAmount)) {
|
||||
|
|
@ -221,23 +307,34 @@ class Product extends Model implements Buyable
|
|||
if ($promo_type == 1) {
|
||||
$discountAmount = $applicablePromotion->discount_value;
|
||||
} else {
|
||||
// on augmente la précision à 3 digits, l'affichage formate les prix sur 2 décimales
|
||||
// On augmente la précision à 3 digits, l'affichage formate les prix sur 2 décimales.
|
||||
$discountAmount = $this->priceHt * ($applicablePromotion->discount_value / 100);
|
||||
$discountAmount = round($discountAmount * 1000) / 1000;
|
||||
}
|
||||
} else {
|
||||
$discountAmount = 0;
|
||||
}
|
||||
return $this->discountAmount = $discountAmount;
|
||||
$this->discountAmount = $discountAmount;
|
||||
return $this->discountAmount;
|
||||
}
|
||||
}
|
||||
|
||||
// taux de remise
|
||||
public function setDiscountRateAttribute($value)
|
||||
/**
|
||||
* set discount rate
|
||||
*
|
||||
* @param float $value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountRateAttribute(float $value)
|
||||
{
|
||||
$this->discountRate = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* get discount rate
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscountRateAttribute()
|
||||
{
|
||||
if (isset($this->discountRate)) {
|
||||
|
|
@ -247,7 +344,7 @@ class Product extends Model implements Buyable
|
|||
if (null !== $applicablePromotion) {
|
||||
$promo_type = $applicablePromotion->discount_type_id;
|
||||
if ($promo_type == 1) {
|
||||
// on veut un pourcentage
|
||||
// On veut un pourcentage.
|
||||
$discountRate = ($applicablePromotion->discount_value / $this->priceHt) * 100;
|
||||
} else {
|
||||
$discountRate = $applicablePromotion->discount_value;
|
||||
|
|
@ -255,61 +352,113 @@ class Product extends Model implements Buyable
|
|||
} else {
|
||||
$discountRate = 0;
|
||||
}
|
||||
return $this->discountRate = $discountRate;
|
||||
$this->discountRate = $discountRate;
|
||||
return $this->discountRate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// //Buyable interface
|
||||
/**
|
||||
* buyablePrice attribute alias
|
||||
*
|
||||
* @param mixed $options
|
||||
* @return float
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function getBuyablePrice($options = null)
|
||||
{
|
||||
// @phpcs:enable
|
||||
return $this->priceHt;
|
||||
}
|
||||
|
||||
// Relations
|
||||
/**
|
||||
* BelongsTo range relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function range()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Range', 'range_id');
|
||||
}
|
||||
|
||||
public function old_slugs()
|
||||
/**
|
||||
* hasMany old_slugs relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function oldSlugs()
|
||||
{
|
||||
return $this->hasMany('App\Model\OldSlug', 'product_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* hasMany stats relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function stats()
|
||||
{
|
||||
return $this->hasMany('App\Models\Stat', 'product_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* belongsToMany orders relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function orders()
|
||||
{
|
||||
return $this->belongsToMany('App\Models\Order', 'orders_products', 'product_id', 'order_id')
|
||||
->withPivot('quantity');
|
||||
}
|
||||
|
||||
// relationship to additionnal product info
|
||||
public function additionnalProductInfo($productType)
|
||||
/**
|
||||
* Pseudo relationship to additionnal product info
|
||||
*
|
||||
* @param string $productType
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function additionnalProductInfo(string $productType)
|
||||
{
|
||||
return $this->$productType;
|
||||
}
|
||||
|
||||
// possible additionnals
|
||||
/**
|
||||
* hasOne foodProduct relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function foodProduct()
|
||||
{
|
||||
return $this->hasOne(FoodProduct::class, 'product_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* hasOne anifoodProduct relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function anifoodProduct()
|
||||
{
|
||||
return $this->hasOne(AnifoodProduct::class, 'product_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* hasOne toolProduct relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function toolProduct()
|
||||
{
|
||||
return $this->hasOne(ToolProduct::class, 'product_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* hasOne garmentProduct relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function garmentProduct()
|
||||
{
|
||||
return $this->hasOne(GarmentProduct::class, 'product_id');
|
||||
|
|
@ -317,13 +466,21 @@ class Product extends Model implements Buyable
|
|||
|
||||
|
||||
|
||||
// relationship to associated products
|
||||
/**
|
||||
* belongsToMany products relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'products_products', 'product_id', 'associated_id');
|
||||
}
|
||||
|
||||
// offres speciales
|
||||
/**
|
||||
* belongsToMany promotions relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function promotions()
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
|
@ -332,13 +489,21 @@ class Product extends Model implements Buyable
|
|||
->whereDate('date_end', '>=', $now);
|
||||
}
|
||||
|
||||
// taxe
|
||||
/**
|
||||
* belongsTo tax relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function tax()
|
||||
{
|
||||
return $this->belongsTo(TaxRate::class, 'tax_rate_id');
|
||||
}
|
||||
|
||||
// tags
|
||||
/**
|
||||
* belongsToMany tags relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function tags()
|
||||
{
|
||||
return $this->belongsToMany(Tag::class);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ class ProductType extends Model
|
|||
'product_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* BelongsTo product relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ class ProductsProducts extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
// useless model it seems
|
||||
// Useless model it seems.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,21 @@ class Promotion extends Model
|
|||
'date_end' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* BelongsToMany products relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(Product::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* BelongsTo discountType relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function discountType()
|
||||
{
|
||||
return $this->belongsTo(DiscountType::class, 'discount_type_id');
|
||||
|
|
|
|||
|
|
@ -9,13 +9,23 @@ class Range extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* hasMany customer relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function products()
|
||||
{
|
||||
return $this->hasMany('App\Models\Product', 'range_id');
|
||||
}
|
||||
|
||||
public function old_slugs()
|
||||
/**
|
||||
* hasMany old_slugs relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function oldSlugs()
|
||||
{
|
||||
return $this->hasMany('App\Model\OldSlug', 'ranges');
|
||||
return $this->hasMany('App\Model\OldSlug', 'range_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ class Salarie extends Model
|
|||
'code'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* BelongsTo customer relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customers::class);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ class Slide extends Model
|
|||
'date_end' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* BelongsTo slider relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function slider()
|
||||
{
|
||||
return $this->belongsTo(Slider::class);
|
||||
|
|
|
|||
|
|
@ -10,11 +10,21 @@ class Slider extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* hasMany slides relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function slides()
|
||||
{
|
||||
return $this->hasMany(Slide::class, 'slider_id')->orderBy('order', 'ASC');
|
||||
}
|
||||
|
||||
/**
|
||||
* filtered slides relation by showable date
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function showableSlides()
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ class Stat extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* BelongsTo product relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Product', 'product_id');
|
||||
|
|
|
|||
|
|
@ -9,8 +9,18 @@ class Tag extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* belongsToMany products relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(Product::class);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,18 @@ class TaxRate extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* hasMany products relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function products()
|
||||
{
|
||||
return $this->hasMany(Product::class, 'tax_rate_id');
|
||||
|
|
|
|||
|
|
@ -9,15 +9,30 @@ class Timeslot extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'order_id', 'magasin_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* BelongsTo order relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* BelongsTo magasin relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function magasin()
|
||||
{
|
||||
return $this->belongsTo(Magasin::class);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ class TimeslotSetting extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* BelongsTo magasin relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function magasin()
|
||||
{
|
||||
return $this->belongsTo(Magasin::class);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@ class User extends Authenticatable
|
|||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* hasMany order relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function orders()
|
||||
{
|
||||
return $this->hasMany('App\Models\Order', 'user_id');
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ class XmlInco extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'no_art',
|
||||
|
|
@ -32,6 +37,11 @@ class XmlInco extends Model
|
|||
'picture',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'picture' => 'array',
|
||||
'nutritional_values' => 'array',
|
||||
|
|
@ -44,6 +54,11 @@ class XmlInco extends Model
|
|||
*/
|
||||
protected $disk = 'inco';
|
||||
|
||||
/**
|
||||
* Storage path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $imagesPath = 'images';
|
||||
|
||||
/**
|
||||
|
|
@ -57,6 +72,8 @@ class XmlInco extends Model
|
|||
|
||||
/**
|
||||
* retrieve a collection of medias
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getMediasAttribute()
|
||||
{
|
||||
|
|
@ -94,159 +111,182 @@ class XmlInco extends Model
|
|||
return Storage::disk($this->disk);
|
||||
}
|
||||
|
||||
/**
|
||||
* getter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNiceStringAttribute()
|
||||
{
|
||||
return sprintf('%s - %s', $this->id, $this->descriptif);
|
||||
}
|
||||
|
||||
/**
|
||||
* update local info
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateLocalProductInfo()
|
||||
{
|
||||
$foodProduct = FoodProduct::where('no_art', $this->id)->first();
|
||||
|
||||
if (!empty($foodProduct)) {
|
||||
// info produits à suggerer lors de l'édition
|
||||
// this->descriptif (doit aller dans la table products)
|
||||
// $table->text('preparation')->nullable(); => $this->conseil_prepa
|
||||
// $table->text('selling_argument')->nullable(); => $this->arg_vente
|
||||
// infos produit maj automatique
|
||||
/** Info produits à suggerer lors de l'édition
|
||||
* this->descriptif (doit aller dans la table products)
|
||||
* $table->text('preparation')->nullable(); => $this->conseil_prepa
|
||||
* $table->text('selling_argument')->nullable(); => $this->arg_vente
|
||||
* infos produit maj automatique
|
||||
*/
|
||||
$foodProduct->ingredients = $this->lst_ing;
|
||||
$foodProduct->allergens = $this->lib_allergene;
|
||||
// $foodProduct->servings = $this->nb_portion; // problem les types de correspondent pas numeric = string (exemple this->nb_portion = '1/2')
|
||||
/** Les types de correspondent pas
|
||||
* numeric ($foodProduct->servings) = string (exemple this->nb_portion = '1/2').
|
||||
*/
|
||||
$nutri_values = $this->nutritional_values;
|
||||
if (!empty($nutri_values)) {
|
||||
// maj des info nutri locales
|
||||
// pour la ref
|
||||
// Maj des info nutri locales.
|
||||
// Pour la ref.
|
||||
$foodProduct->nv_ref_weight_g = $nutri_values["taille_ref"];
|
||||
$foodProduct->nv_kj = $nutri_values["val_energ_kj_r"];
|
||||
// Energie Kj
|
||||
// Energie Kj.
|
||||
$foodProduct->nv_kj = $nutri_values["val_energ_kj_r"];
|
||||
// Energie Kcal.
|
||||
$foodProduct->nv_kcal = $nutri_values["val_energ_kcal_r"];
|
||||
// Energie Kcal
|
||||
// Graisses.
|
||||
$foodProduct->nv_fat_g = $nutri_values["mat_grass_r"];
|
||||
// graisses
|
||||
// Dont acides gras saturés.
|
||||
$foodProduct->nv_sat_fat_g = $nutri_values["ags_r"];
|
||||
// dont acides gras saturés
|
||||
// Glucides.
|
||||
$foodProduct->nv_carb_g = $nutri_values["glucides_r"];
|
||||
// Glucides
|
||||
// Dont sucres.
|
||||
$foodProduct->nv_sugar_g = $nutri_values["sucre_r"];
|
||||
// dont sucres
|
||||
// Fibres alimentaires.
|
||||
$foodProduct->nv_fiber_g = $nutri_values["fib_alim_r"];
|
||||
// fibres alimentaires
|
||||
// Protéines.
|
||||
$foodProduct->nv_protein_g = $nutri_values["proteine_r"];
|
||||
// protéines
|
||||
// Sel.
|
||||
$foodProduct->nv_salt_g = $nutri_values["sel_r"];
|
||||
// sel
|
||||
// $foodProduct-> = $nutri_values["sodium_r"];
|
||||
// $foodProduct-> = $nutri_values["ener_e14_r"];
|
||||
// $foodProduct-> = $nutri_values["fruits_r"];
|
||||
// $foodProduct-> = $nutri_values["fruits_coque_sech_r"];
|
||||
// $foodProduct-> = $nutri_values["ener_kjo_r"];
|
||||
// $foodProduct-> = $nutri_values["fatsat_r"];
|
||||
// $foodProduct-> = $nutri_values["choval_r"];
|
||||
// $foodProduct-> = $nutri_values["sugar_r"];
|
||||
// $foodProduct-> = $nutri_values["fibtg_r"];
|
||||
// $foodProduct-> = $nutri_values["pro_r"];
|
||||
// $foodProduct-> = $nutri_values["salteq_r"];
|
||||
// valeurs nutritionnelles par portion
|
||||
|
||||
/** Autres valeurs dispos
|
||||
* $nutri_values["sodium_r"];
|
||||
* $nutri_values["ener_e14_r"];
|
||||
* $nutri_values["fruits_r"];
|
||||
* $nutri_values["fruits_coque_sech_r"];
|
||||
* $nutri_values["ener_kjo_r"];
|
||||
* $nutri_values["fatsat_r"];
|
||||
* $nutri_values["choval_r"];
|
||||
* $nutri_values["sugar_r"];
|
||||
* $nutri_values["fibtg_r"];
|
||||
* $nutri_values["pro_r"];
|
||||
* $nutri_values["salteq_r"];
|
||||
*/
|
||||
// Valeurs nutritionnelles par portion.
|
||||
// Taille portion en grammes.
|
||||
$foodProduct->nv_serving_size_g = $nutri_values["taille_port"];
|
||||
// taille portion en grammes
|
||||
// Energie Kj.
|
||||
$foodProduct->nv_serving_kj = $nutri_values["val_energ_kj_p"];
|
||||
// Energie Kj
|
||||
// Energie Kcal.
|
||||
$foodProduct->nv_serving_kcal = $nutri_values["val_energ_kcal_p"];
|
||||
// Energie Kcal
|
||||
// Graisses.
|
||||
$foodProduct->nv_serving_fat_g = $nutri_values["mat_grass_p"];
|
||||
// graisses
|
||||
// Dont acides gras saturés.
|
||||
$foodProduct->nv_serving_sat_fat_g = $nutri_values["ags_p"];
|
||||
// dont acides gras saturés
|
||||
// Glucides.
|
||||
$foodProduct->nv_serving_carb_g = $nutri_values["glucides_p"];
|
||||
// Glucides
|
||||
// Dont sucres.
|
||||
$foodProduct->nv_serving_sugar_g = $nutri_values["sucre_p"];
|
||||
// dont sucres
|
||||
// Fibres alimentaires.
|
||||
$foodProduct->nv_serving_fiber_g = $nutri_values["fib_alim_p"];
|
||||
// fibres alimentaires
|
||||
// Protéines.
|
||||
$foodProduct->nv_serving_protein_g = $nutri_values["proteine_p"];
|
||||
// protéines
|
||||
// Sel.
|
||||
$foodProduct->nv_serving_salt_g = $nutri_values["sel_p"];
|
||||
// sel
|
||||
// $foodProduct-> = $nutri_values["sodium_p"];
|
||||
// $foodProduct-> = $nutri_values["fruits_p"];
|
||||
// apports journaliers
|
||||
|
||||
/**
|
||||
* autres valeurs disponibles
|
||||
* $nutri_values["sodium_p"];
|
||||
* $nutri_values["fruits_p"];
|
||||
*/
|
||||
|
||||
// Apports journaliers.
|
||||
// Energie % recommandé.
|
||||
$foodProduct->nv_daily_energy = $nutri_values["pourcent_apport_ref_kjo_r"];
|
||||
// Energie % recommandé
|
||||
// Graisses.
|
||||
$foodProduct->nv_daily_fat = $nutri_values["pourcent_apport_ref_fat_r"];
|
||||
// graisses
|
||||
// Dont acides gras saturés.
|
||||
$foodProduct->nv_daily_sat_fat = $nutri_values["pourcent_apport_ref_fatsat_r"];
|
||||
// dont acides gras saturés
|
||||
// Glucides.
|
||||
$foodProduct->nv_daily_carb = $nutri_values["pourcent_apport_ref_choval_r"];
|
||||
// Glucides
|
||||
// Dont sucres.
|
||||
$foodProduct->nv_daily_sugar = $nutri_values["pourcent_apport_ref_sugar_r"];
|
||||
// dont sucres
|
||||
// Fibres alimentaires.
|
||||
$foodProduct->nv_daily_fiber = $nutri_values["pourcent_apport_ref_fibtg_r"];
|
||||
// fibres alimentaires
|
||||
// Protéines.
|
||||
$foodProduct->nv_daily_protein = $nutri_values["pourcent_apport_ref_pro_r"];
|
||||
// protéines
|
||||
// Sel.
|
||||
$foodProduct->nv_daily_salt = $nutri_values["pourcent_apport_ref_salteq_r"];
|
||||
// sel
|
||||
// $foodProduct-> = $nutri_values["pourcent_apport_ref_e14_r"];
|
||||
// nutriscore
|
||||
|
||||
// Autre valeur dispo $nutri_values["pourcent_apport_ref_e14_r"] .
|
||||
// Nutriscore.
|
||||
$foodProduct->nutriscore = $nutri_values["classement"];
|
||||
|
||||
|
||||
// Infos n'ayant pas de mapping
|
||||
// $foodProduct-> = $nutri_values["val_energ_kj_nut"];
|
||||
// $foodProduct-> = $nutri_values["val_energ_kcal_nut"];
|
||||
// $foodProduct-> = $nutri_values["mat_grass_nut"];
|
||||
// $foodProduct-> = $nutri_values["ags_nut"];
|
||||
// $foodProduct-> = $nutri_values["glucides_nut"];
|
||||
// $foodProduct-> = $nutri_values["sucre_nut"];
|
||||
// $foodProduct-> = $nutri_values["sucre_r"];
|
||||
// $foodProduct-> = $nutri_values["fib_alim_nut"];
|
||||
// $foodProduct-> = $nutri_values["proteine_nut"];
|
||||
// $foodProduct-> = $nutri_values["sel_nut"];
|
||||
// $foodProduct-> = $nutri_values["apport_ref"];
|
||||
// $foodProduct-> = $nutri_values["fruits_coque_sech_p"];
|
||||
// $foodProduct-> = $nutri_values["ener_e14_p"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_apport_ref_e14_p"];
|
||||
// $foodProduct-> = $nutri_values["ener_kjo_p"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_apport_ref_kjo_p"];
|
||||
// $foodProduct-> = $nutri_values["fat_p"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_apport_ref_fat_p"];
|
||||
// $foodProduct-> = $nutri_values["fatsat_p"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_apport_ref_fatsat_p"];
|
||||
// $foodProduct-> = $nutri_values["choval_p"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_apport_ref_choval_p"];
|
||||
// $foodProduct-> = $nutri_values["sugar_p"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_apport_ref_sugar_p"];
|
||||
// $foodProduct-> = $nutri_values["fibtg_p"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_apport_ref_fibtg_p"];
|
||||
// $foodProduct-> = $nutri_values["pro_p"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_apport_ref_pro_p"];
|
||||
// $foodProduct-> = $nutri_values["salteq_p"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_apport_ref_salteq_p"];
|
||||
// $foodProduct-> = $nutri_values["apport_port"];
|
||||
// $foodProduct-> = $nutri_values["part_p"];
|
||||
// $foodProduct-> = $nutri_values["part_g"];
|
||||
// $foodProduct-> = $nutri_values["part_l"];
|
||||
// $foodProduct-> = $nutri_values["p_sur_l"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_ags"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_agi"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_ss"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_amidon"];
|
||||
// $foodProduct-> = $nutri_values["composante_n"];
|
||||
// $foodProduct-> = $nutri_values["composante_p"];
|
||||
// $foodProduct-> = $nutri_values["pourcent_fruits"];
|
||||
// $foodProduct-> = $nutri_values["mat_grass_r_prec"];
|
||||
// $foodProduct-> = $nutri_values["ags_r_prec"];
|
||||
// $foodProduct-> = $nutri_values["glucides_r_prec"];
|
||||
// $foodProduct-> = $nutri_values["sucre_r_prec"];
|
||||
// $foodProduct-> = $nutri_values["fib_alim_r_prec"];
|
||||
// $foodProduct-> = $nutri_values["proteine_r_prec"];
|
||||
// $foodProduct-> = $nutri_values["sel_r_prec"];
|
||||
// $foodProduct-> = $nutri_values["sodium_r_prec"];
|
||||
// $foodProduct-> = $nutri_values["fruits_r_prec"];
|
||||
// $foodProduct-> = $nutri_values["fruits_coque_sech_r_prec"];
|
||||
// $foodProduct-> = $nutri_values["score_nutri"];
|
||||
/**
|
||||
* Infos n'ayant pas de mapping
|
||||
*
|
||||
* $nutri_values["val_energ_kj_nut"];
|
||||
* $nutri_values["val_energ_kcal_nut"];
|
||||
* $nutri_values["mat_grass_nut"];
|
||||
* $nutri_values["ags_nut"];
|
||||
* $nutri_values["glucides_nut"];
|
||||
* $nutri_values["sucre_nut"];
|
||||
* $nutri_values["sucre_r"];
|
||||
* $nutri_values["fib_alim_nut"];
|
||||
* $nutri_values["proteine_nut"];
|
||||
* $nutri_values["sel_nut"];
|
||||
* $nutri_values["apport_ref"];
|
||||
* $nutri_values["fruits_coque_sech_p"];
|
||||
* $nutri_values["ener_e14_p"];
|
||||
* $nutri_values["pourcent_apport_ref_e14_p"];
|
||||
* $nutri_values["ener_kjo_p"];
|
||||
* $nutri_values["pourcent_apport_ref_kjo_p"];
|
||||
* $nutri_values["fat_p"];
|
||||
* $nutri_values["pourcent_apport_ref_fat_p"];
|
||||
* $nutri_values["fatsat_p"];
|
||||
* $nutri_values["pourcent_apport_ref_fatsat_p"];
|
||||
* $nutri_values["choval_p"];
|
||||
* $nutri_values["pourcent_apport_ref_choval_p"];
|
||||
* $nutri_values["sugar_p"];
|
||||
* $nutri_values["pourcent_apport_ref_sugar_p"];
|
||||
* $nutri_values["fibtg_p"];
|
||||
* $nutri_values["pourcent_apport_ref_fibtg_p"];
|
||||
* $nutri_values["pro_p"];
|
||||
* $nutri_values["pourcent_apport_ref_pro_p"];
|
||||
* $nutri_values["salteq_p"];
|
||||
* $nutri_values["pourcent_apport_ref_salteq_p"];
|
||||
* $nutri_values["apport_port"];
|
||||
* $nutri_values["part_p"];
|
||||
* $nutri_values["part_g"];
|
||||
* $nutri_values["part_l"];
|
||||
* $nutri_values["p_sur_l"];
|
||||
* $nutri_values["pourcent_ags"];
|
||||
* $nutri_values["pourcent_agi"];
|
||||
* $nutri_values["pourcent_ss"];
|
||||
* $nutri_values["pourcent_amidon"];
|
||||
* $nutri_values["composante_n"];
|
||||
* $nutri_values["composante_p"];
|
||||
* $nutri_values["pourcent_fruits"];
|
||||
* $nutri_values["mat_grass_r_prec"];
|
||||
* $nutri_values["ags_r_prec"];
|
||||
* $nutri_values["glucides_r_prec"];
|
||||
* $nutri_values["sucre_r_prec"];
|
||||
* $nutri_values["fib_alim_r_prec"];
|
||||
* $nutri_values["proteine_r_prec"];
|
||||
* $nutri_values["sel_r_prec"];
|
||||
* $nutri_values["sodium_r_prec"];
|
||||
* $nutri_values["fruits_r_prec"];
|
||||
* $nutri_values["fruits_coque_sech_r_prec"];
|
||||
* $nutri_values["score_nutri"];
|
||||
*/
|
||||
}//end if
|
||||
|
||||
$foodProduct->save();
|
||||
}//end if
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,15 +21,20 @@ class ProductPolicy
|
|||
}
|
||||
|
||||
/**
|
||||
* $user is a App\Models\User or a App\Models\Customers
|
||||
* @param App\Models\User|App\Models\Customers $user
|
||||
* @param \App\Models\Product $product
|
||||
*
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||
*/
|
||||
public function addToCart($user = null, Product $product)
|
||||
public function addToCart($user, Product $product)
|
||||
{
|
||||
// phpcs:enable
|
||||
$now = Carbon::now();
|
||||
if ($product->orderable_start === null or $product->orderable_start <= $now) {
|
||||
// on est entré dans la période commandable ou c'est commandable depuis toujours
|
||||
// On est entré dans la période commandable ou c'est commandable depuis toujours.
|
||||
if ($product->orderable_end === null or $product->orderable_end >= $now) {
|
||||
// il n'y a pas de limite dans le temps ou elle n'est pas encore passée
|
||||
// Il n'y a pas de limite dans le temps ou elle n'est pas encore passée.
|
||||
return Response::allow();
|
||||
}
|
||||
return Response::deny('Ce produit n\'est pas disponible pour le moment');
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Illuminate\Support\Facades\View;
|
|||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
\URL::forceScheme('https');
|
||||
URL::forceScheme('https');
|
||||
if (config('app.env') !== 'local') {
|
||||
setlocale(LC_TIME, config('app.locale') . "_" . strtoupper(config('app.locale')) . '.utf8');
|
||||
}
|
||||
|
|
@ -38,49 +38,28 @@ class AppServiceProvider extends ServiceProvider
|
|||
setlocale(LC_TIME, strtoupper(config('app.locale')) . "_" . config('app.locale') . '.utf8');
|
||||
}
|
||||
|
||||
// bo settings as config
|
||||
// this is useful when setting up the app whene settings table doesn't exist yet
|
||||
try {
|
||||
config([
|
||||
'bosettings' => Setting::all()
|
||||
->keyBy('key')
|
||||
// key every setting by its name
|
||||
->transform(function ($setting) {
|
||||
return $setting->value;
|
||||
// return only the value
|
||||
})
|
||||
->toArray()
|
||||
// make it an array
|
||||
]);
|
||||
} catch (QueryException $e) {
|
||||
// nevermind, you should run php artisan migrate before going any further.
|
||||
}
|
||||
// this is useful when setting up the app whene ranges table doesn't exist yet
|
||||
try {
|
||||
// on partage les ranges (gammes produit)
|
||||
$ranges = Range::where('status', '1')->get();
|
||||
} catch (QueryException $e) {
|
||||
$ranges = null;
|
||||
}
|
||||
config([
|
||||
'bosettings' => Setting::all()
|
||||
->keyBy('key')
|
||||
// Key every setting by its name.
|
||||
->transform(function ($setting) {
|
||||
return $setting->value;
|
||||
// Return only the value.
|
||||
})
|
||||
->toArray()
|
||||
// Make it an array.
|
||||
]);
|
||||
|
||||
// On partage les ranges (gammes produit).
|
||||
$ranges = Range::where('status', '1')->get();
|
||||
View::share('published_ranges', $ranges);
|
||||
|
||||
// this is useful when setting up the app when tags table doesn't exist yet
|
||||
try {
|
||||
// on partage les tags
|
||||
$tags = Tag::where('status', '1')->orderBy('order', 'ASC')->get();
|
||||
} catch (QueryException $e) {
|
||||
$tags = null;
|
||||
}
|
||||
// On partage les tags.
|
||||
$tags = Tag::where('status', '1')->orderBy('order', 'ASC')->get();
|
||||
View::share('published_tags', $tags);
|
||||
|
||||
// @TODO : Supprimer cet element front_settings
|
||||
// this is useful when setting up the app whene settings table doesn't exist yet
|
||||
try {
|
||||
$front_settings = Setting::where('key', 'LIKE', 'theme_%')->get();
|
||||
} catch (QueryException $e) {
|
||||
$front_settings = null;
|
||||
}
|
||||
// front theme settings
|
||||
$front_settings = Setting::where('key', 'LIKE', 'theme_%')->get();
|
||||
// Front theme settings.
|
||||
View::share('front_settings', $front_settings);
|
||||
|
||||
Blade::directive('fmt_currency', function ($expression) {
|
||||
|
|
@ -105,7 +84,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
return "<?php echo Illuminate\Support\Str::limit($expression,$limit) ?>";
|
||||
});
|
||||
|
||||
// default paginator template for back Office
|
||||
// Default paginator template for back Office.
|
||||
Paginator::useBootstrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,15 +6,6 @@ use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvid
|
|||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,15 +19,6 @@ class RouteServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public const HOME = '/';
|
||||
|
||||
/**
|
||||
* The controller namespace for the application.
|
||||
*
|
||||
* When present, controller route declarations will automatically be prefixed with this namespace.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
// protected $namespace = 'App\\Http\\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ use Carbon\Carbon;
|
|||
|
||||
class Adult implements Rule
|
||||
{
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $error_messages = "la date de naissance est incorrecte";
|
||||
|
||||
/**
|
||||
|
|
@ -21,12 +26,15 @@ class Adult implements Rule
|
|||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
* @return boolean
|
||||
*
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
//@phpcs:enable
|
||||
$MJ = Carbon::now()->subYears(18);
|
||||
|
||||
if ($this->isSqlDate($value)) {
|
||||
|
|
@ -46,7 +54,7 @@ class Adult implements Rule
|
|||
return false;
|
||||
}
|
||||
|
||||
// pass
|
||||
// Pass.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +68,13 @@ class Adult implements Rule
|
|||
return $this->error_messages;
|
||||
}
|
||||
|
||||
private function isSqlDate($date)
|
||||
/**
|
||||
* Check if provided string is formatted for mysql
|
||||
*
|
||||
* @param string $date
|
||||
* @return boolean
|
||||
*/
|
||||
private function isSqlDate(string $date)
|
||||
{
|
||||
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $date)) {
|
||||
return true;
|
||||
|
|
@ -68,7 +82,13 @@ class Adult implements Rule
|
|||
return false;
|
||||
}
|
||||
|
||||
private function isFormDate($date)
|
||||
/**
|
||||
* Check if provided string is formatted DD/MM/AAAA
|
||||
*
|
||||
* @param string $date
|
||||
* @return boolean
|
||||
*/
|
||||
private function isFormDate(string $date)
|
||||
{
|
||||
if (preg_match("/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/[0-9]{4}$/", $date)) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ return [
|
|||
/*
|
||||
* Laravel Framework Service Providers...
|
||||
*/
|
||||
|
||||
Illuminate\Auth\AuthServiceProvider::class,
|
||||
Illuminate\Broadcasting\BroadcastServiceProvider::class,
|
||||
Illuminate\Bus\BusServiceProvider::class,
|
||||
|
|
@ -180,9 +181,9 @@ return [
|
|||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
Gloudemans\Shoppingcart\ShoppingcartServiceProvider::class,
|
||||
|
|
@ -239,7 +240,7 @@ return [
|
|||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
// Enums
|
||||
// Enums.
|
||||
'LogType' => \App\Enums\LogType::class,
|
||||
'SettingRegisterMode' => \App\Enums\SettingRegisterMode::class,
|
||||
'SellUnit' => \App\Enums\SellUnit::class,
|
||||
|
|
|
|||
|
|
@ -80,11 +80,6 @@ return [
|
|||
'driver' => 'eloquent',
|
||||
'model' => App\Models\Customers::class,
|
||||
]
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
// When route-bound breadcrumbs are used but the current route doesn't have a name (UnnamedRouteException)
|
||||
// When route-bound breadcrumbs are used but the current route doesn't have a name (UnnamedRouteException).
|
||||
'unnamed-route-exception' => true,
|
||||
|
||||
// When route-bound breadcrumbs are used and the matching breadcrumb doesn't exist (InvalidBreadcrumbException)
|
||||
// When route-bound breadcrumbs are used and the matching breadcrumb doesn't exist (InvalidBreadcrumbException).
|
||||
'missing-route-bound-breadcrumb-exception' => true,
|
||||
|
||||
// When a named breadcrumb is used but doesn't exist (InvalidBreadcrumbException)
|
||||
// When a named breadcrumb is used but doesn't exist (InvalidBreadcrumbException).
|
||||
'invalid-named-breadcrumb-exception' => true,
|
||||
|
||||
/*
|
||||
|
|
@ -68,10 +68,10 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
// Manager
|
||||
// Manager.
|
||||
'manager-class' => Diglactic\Breadcrumbs\Manager::class,
|
||||
|
||||
// Generator
|
||||
// Generator.
|
||||
'generator-class' => Diglactic\Breadcrumbs\Generator::class,
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -60,9 +60,6 @@ return [
|
|||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
// 'calculator' => \Gloudemans\Shoppingcart\Calculation\DefaultCalculator::class,
|
||||
'calculator' => \App\Lib\LDC\CartCalculator::class,
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -90,7 +90,10 @@ return [
|
|||
|
||||
'contactsList' => [
|
||||
'serviceweb' => explode(",", env('MAIL_LIST_SERVICEWEB', 'equipe.web@ldc.fr')),
|
||||
'invalidInco' => explode(",", env('MAIL_LIST_INVALIDINCO', 'equipe.web@ldc.fr,vincent.pierre@ldc.fr,christelle.manceau@ldc.fr')),
|
||||
'invalidInco' => explode(
|
||||
",",
|
||||
env('MAIL_LIST_INVALIDINCO', 'equipe.web@ldc.fr,vincent.pierre@ldc.fr,christelle.manceau@ldc.fr')
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class UserFactory extends Factory
|
|||
'email' => $this->faker->unique()->safeEmail,
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
|
||||
// password
|
||||
// Password is password .
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ class CreateShoppingcartTable extends Migration
|
|||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
|
@ -23,6 +25,8 @@ class CreateShoppingcartTable extends Migration
|
|||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,12 +15,16 @@ class AddFieldsToProducts extends Migration
|
|||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->string('picture_large')->nullable()->after('picture');
|
||||
$table->string('sell_unit')->nullable()->after('stock'); //lier à une liste de valeurs
|
||||
$table->string('sell_unit')->nullable()->after('stock');
|
||||
// Lier à une liste de valeurs.
|
||||
$table->unsignedFloat('weight')->nullable()->after('sell_unit');
|
||||
$table->string('weight_unit')->nullable()->after('weight'); //lier à une liste de valeurs
|
||||
$table->string('product_type')->default('foodProduct')->after('id'); //lier à une liste de valeurs
|
||||
//mise en avant
|
||||
$table->boolean('star')->default(0)->after('slug'); //produit star
|
||||
$table->string('weight_unit')->nullable()->after('weight');
|
||||
// Lier à une liste de valeurs.
|
||||
$table->string('product_type')->default('foodProduct')->after('id');
|
||||
// Lier à une liste de valeurs.
|
||||
// Mise en avant.
|
||||
$table->boolean('star')->default(0)->after('slug');
|
||||
// Produit star.
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ class CreateFoodProducts extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
//données sur produit alimentaires
|
||||
// Données sur produit alimentaires.
|
||||
Schema::create('food_products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
//liaison à la table produits
|
||||
// Liaison à la table produits.
|
||||
$table->foreignId('product_id')->constrained('products');
|
||||
|
||||
$table->unsignedInteger('no_art')->nullable();
|
||||
|
||||
//autre info (venues de INCO)
|
||||
// Autre info (venues de INCO).
|
||||
$table->text('ingredients')->nullable();
|
||||
$table->text('preparation')->nullable();
|
||||
$table->unsignedInteger('servings')->nullable();
|
||||
|
|
@ -30,41 +30,66 @@ class CreateFoodProducts extends Migration
|
|||
$table->text('selling_argument')->nullable();
|
||||
|
||||
|
||||
//valeurs nutritionnelles ref
|
||||
$table->unsignedFloat('nv_ref_weight_g')->nullable(); //taille de la référence en grammes
|
||||
$table->unsignedFloat('nv_kj')->nullable(); //Energie Kj
|
||||
$table->unsignedFloat('nv_kcal')->nullable(); //Energie Kcal
|
||||
$table->unsignedFloat('nv_fat_g')->nullable(); //graisses
|
||||
$table->unsignedFloat('nv_sat_fat_g')->nullable(); //dont acides gras saturés
|
||||
$table->unsignedFloat('nv_carb_g')->nullable(); //Glucides
|
||||
$table->unsignedFloat('nv_sugar_g')->nullable(); //dont sucres
|
||||
$table->unsignedFloat('nv_fiber_g')->nullable(); //fibres alimentaires
|
||||
$table->unsignedFloat('nv_protein_g')->nullable(); //protéines
|
||||
$table->unsignedFloat('nv_salt_g')->nullable(); //sel
|
||||
|
||||
//valeurs nutritionnelles par portion
|
||||
$table->unsignedFloat('nv_serving_size_g')->nullable(); //taille portion en grammes
|
||||
$table->unsignedFloat('nv_serving_kj')->nullable(); //Energie Kj
|
||||
$table->unsignedFloat('nv_serving_kcal')->nullable(); //Energie Kcal
|
||||
$table->unsignedFloat('nv_serving_fat_g')->nullable(); //graisses
|
||||
$table->unsignedFloat('nv_serving_sat_fat_g')->nullable(); //dont acides gras saturés
|
||||
$table->unsignedFloat('nv_serving_carb_g')->nullable(); //Glucides
|
||||
$table->unsignedFloat('nv_serving_sugar_g')->nullable(); //dont sucres
|
||||
$table->unsignedFloat('nv_serving_fiber_g')->nullable(); //fibres alimentaires
|
||||
$table->unsignedFloat('nv_serving_protein_g')->nullable(); //protéines
|
||||
$table->unsignedFloat('nv_serving_salt_g')->nullable(); //sel
|
||||
|
||||
//apports journaliers
|
||||
$table->unsignedFloat('nv_daily_energy')->nullable(); //Energie % recommandé
|
||||
$table->unsignedFloat('nv_daily_fat')->nullable(); //graisses
|
||||
$table->unsignedFloat('nv_daily_sat_fat')->nullable(); //dont acides gras saturés
|
||||
$table->unsignedFloat('nv_daily_carb')->nullable(); //Glucides
|
||||
$table->unsignedFloat('nv_daily_sugar')->nullable(); //dont sucres
|
||||
$table->unsignedFloat('nv_daily_fiber')->nullable(); //fibres alimentaires
|
||||
$table->unsignedFloat('nv_daily_protein')->nullable(); //protéines
|
||||
$table->unsignedFloat('nv_daily_salt')->nullable(); //sel
|
||||
|
||||
//nutriscore
|
||||
// Valeurs nutritionnelles ref.
|
||||
$table->unsignedFloat('nv_ref_weight_g')->nullable();
|
||||
// Taille de la référence en grammes.
|
||||
$table->unsignedFloat('nv_kj')->nullable();
|
||||
// Energie Kj.
|
||||
$table->unsignedFloat('nv_kcal')->nullable();
|
||||
// Energie Kcal.
|
||||
$table->unsignedFloat('nv_fat_g')->nullable();
|
||||
// Graisses.
|
||||
$table->unsignedFloat('nv_sat_fat_g')->nullable();
|
||||
// Dont acides gras saturés.
|
||||
$table->unsignedFloat('nv_carb_g')->nullable();
|
||||
// Glucides.
|
||||
$table->unsignedFloat('nv_sugar_g')->nullable();
|
||||
// Dont sucres.
|
||||
$table->unsignedFloat('nv_fiber_g')->nullable();
|
||||
// Fibres alimentaires.
|
||||
$table->unsignedFloat('nv_protein_g')->nullable();
|
||||
// Protéines.
|
||||
$table->unsignedFloat('nv_salt_g')->nullable();
|
||||
// Sel.
|
||||
// Valeurs nutritionnelles par portion.
|
||||
$table->unsignedFloat('nv_serving_size_g')->nullable();
|
||||
// Taille portion en grammes.
|
||||
$table->unsignedFloat('nv_serving_kj')->nullable();
|
||||
// Energie Kj.
|
||||
$table->unsignedFloat('nv_serving_kcal')->nullable();
|
||||
// Energie Kcal.
|
||||
$table->unsignedFloat('nv_serving_fat_g')->nullable();
|
||||
// Graisses.
|
||||
$table->unsignedFloat('nv_serving_sat_fat_g')->nullable();
|
||||
// Dont acides gras saturés.
|
||||
$table->unsignedFloat('nv_serving_carb_g')->nullable();
|
||||
// Glucides.
|
||||
$table->unsignedFloat('nv_serving_sugar_g')->nullable();
|
||||
// Dont sucres.
|
||||
$table->unsignedFloat('nv_serving_fiber_g')->nullable();
|
||||
// Fibres alimentaires.
|
||||
$table->unsignedFloat('nv_serving_protein_g')->nullable();
|
||||
// Protéines.
|
||||
$table->unsignedFloat('nv_serving_salt_g')->nullable();
|
||||
// Sel.
|
||||
// Apports journaliers.
|
||||
$table->unsignedFloat('nv_daily_energy')->nullable();
|
||||
// Energie % recommandé.
|
||||
$table->unsignedFloat('nv_daily_fat')->nullable();
|
||||
// Graisses.
|
||||
$table->unsignedFloat('nv_daily_sat_fat')->nullable();
|
||||
// Dont acides gras saturés.
|
||||
$table->unsignedFloat('nv_daily_carb')->nullable();
|
||||
// Glucides.
|
||||
$table->unsignedFloat('nv_daily_sugar')->nullable();
|
||||
// Dont sucres.
|
||||
$table->unsignedFloat('nv_daily_fiber')->nullable();
|
||||
// Fibres alimentaires.
|
||||
$table->unsignedFloat('nv_daily_protein')->nullable();
|
||||
// Protéines.
|
||||
$table->unsignedFloat('nv_daily_salt')->nullable();
|
||||
// Sel.
|
||||
// Nutriscore.
|
||||
$table->string('nutriscore')->nullable();
|
||||
$table->text('nutriscore_args')->nullable();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ class CreateProductsProducts extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::create('products_products', function (Blueprint $table) {
|
||||
//association de produits
|
||||
|
||||
$table->foreignId('product_id')->constrained('products'); //produit considéré
|
||||
$table->foreignId('associated_id')->constrained('products'); //produit à afficher dans 'vous aimerez aussi'
|
||||
// Association de produits.
|
||||
$table->foreignId('product_id')->constrained('products');
|
||||
// Produit considéré.
|
||||
$table->foreignId('associated_id')->constrained('products');
|
||||
// Produit à afficher dans 'vous aimerez aussi'.
|
||||
$table->collation = 'utf8mb4_unicode_ci';
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ class CreateOrderLinesTable extends Migration
|
|||
|
||||
$table->foreignId('order_id')->constrained('orders');
|
||||
$table->foreignId('product_id')->nullable()->constrained('products');
|
||||
//future foreign keys to shipping tables, and other expanses which are not products
|
||||
// Future foreign keys to shipping tables, and other expanses which are not products.
|
||||
$table->unsignedInteger('quantity')->default(1);
|
||||
//nullable fields below
|
||||
// Nullable fields below.
|
||||
$table->float('unit_price')->default(0);
|
||||
$table->float('unit_tax')->default(0);
|
||||
$table->float('unit_discount')->default(0);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@ class CreateProductPromotionTable extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::create('product_promotion', function (Blueprint $table) {
|
||||
$table->foreignId('product_id')->constrained('products'); //produit considéré
|
||||
$table->foreignId('promotion_id')->constrained('promotions'); //promotion associée
|
||||
$table->foreignId('product_id')->constrained('products');
|
||||
// Produit considéré.
|
||||
$table->foreignId('promotion_id')->constrained('promotions');
|
||||
// Promotion associée.
|
||||
$table->collation = 'utf8mb4_unicode_ci';
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@ class CreateProductTagTable extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::create('product_tag', function (Blueprint $table) {
|
||||
$table->foreignId('product_id')->constrained('products'); //produit considéré
|
||||
$table->foreignId('tag_id')->constrained('tags'); //tag associée
|
||||
$table->foreignId('product_id')->constrained('products');
|
||||
// Produit considéré.
|
||||
$table->foreignId('tag_id')->constrained('tags');
|
||||
// Tag associée.
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue