diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ab42c78..d465299 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -23,7 +23,7 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - // write schedules here + // Write schedules here. } /** diff --git a/app/Enums/Page.php b/app/Enums/Page.php index e8848d4..78a95c8 100644 --- a/app/Enums/Page.php +++ b/app/Enums/Page.php @@ -31,6 +31,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable; */ class Page extends BaseEnumRoutable { + /** + * Enum values + * + * @return array + */ protected static function values(): array { return [ diff --git a/app/Enums/Role.php b/app/Enums/Role.php index 730b402..744dc44 100644 --- a/app/Enums/Role.php +++ b/app/Enums/Role.php @@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable; */ class Role extends BaseEnumRoutable { + /** + * Enum values + * + * @return array + */ protected static function values(): array { return [ diff --git a/app/Http/Controllers/Auth/ConfirmPasswordController.php b/app/Http/Controllers/Auth/ConfirmPasswordController.php index f6112b2..af3a5e4 100644 --- a/app/Http/Controllers/Auth/ConfirmPasswordController.php +++ b/app/Http/Controllers/Auth/ConfirmPasswordController.php @@ -8,6 +8,8 @@ use Illuminate\Foundation\Auth\ConfirmsPasswords; class ConfirmPasswordController extends Controller { + use ConfirmsPasswords; + /* |-------------------------------------------------------------------------- | Confirm Password Controller @@ -18,7 +20,6 @@ class ConfirmPasswordController extends Controller | this trait and override any functions that require customization. | */ - use ConfirmsPasswords; /** * Where to redirect users when the intended url fails. diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 75ef4e6..b68fe6d 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -7,6 +7,8 @@ use Illuminate\Foundation\Auth\SendsPasswordResetEmails; class ForgotPasswordController extends Controller { + use SendsPasswordResetEmails; + /* |-------------------------------------------------------------------------- | Password Reset Controller @@ -17,5 +19,6 @@ class ForgotPasswordController extends Controller | your application to your users. Feel free to explore this trait. | */ - use SendsPasswordResetEmails; + + // On fait rien. } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 74705c8..2e25fd4 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -28,6 +28,8 @@ use Illuminate\Foundation\Auth\AuthenticatesUsers; */ class LoginController extends Controller { + use AuthenticatesUsers; + /* |-------------------------------------------------------------------------- | Login Controller @@ -38,7 +40,6 @@ class LoginController extends Controller | to conveniently provide its functionality to your applications. | */ - use AuthenticatesUsers; /** * Where to redirect users after login. diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 15cb0fa..d9cb3be 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -11,6 +11,8 @@ use Illuminate\Support\Facades\Validator; class RegisterController extends Controller { + use RegistersUsers; + /* |-------------------------------------------------------------------------- | Register Controller @@ -21,7 +23,6 @@ class RegisterController extends Controller | provide this functionality without requiring any additional code. | */ - use RegistersUsers; /** * Where to redirect users after registration. diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index fa4081b..9f994b1 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -8,6 +8,8 @@ use Illuminate\Foundation\Auth\ResetsPasswords; class ResetPasswordController extends Controller { + use ResetsPasswords; + /* |-------------------------------------------------------------------------- | Password Reset Controller @@ -18,7 +20,6 @@ class ResetPasswordController extends Controller | explore this trait and override any methods you wish to tweak. | */ - use ResetsPasswords; /** * Where to redirect users after resetting their password. diff --git a/app/Http/Controllers/Auth/VerificationController.php b/app/Http/Controllers/Auth/VerificationController.php index 74ab841..36666ec 100644 --- a/app/Http/Controllers/Auth/VerificationController.php +++ b/app/Http/Controllers/Auth/VerificationController.php @@ -8,6 +8,8 @@ use Illuminate\Foundation\Auth\VerifiesEmails; class VerificationController extends Controller { + use VerifiesEmails; + /* |-------------------------------------------------------------------------- | Email Verification Controller @@ -18,7 +20,6 @@ class VerificationController extends Controller | be re-sent if the user didn't receive the original email message. | */ - use VerifiesEmails; /** * Where to redirect users after verification. diff --git a/app/Http/Controllers/Bo/AdviceController.php b/app/Http/Controllers/Bo/AdviceController.php index a91534a..679e0e9 100644 --- a/app/Http/Controllers/Bo/AdviceController.php +++ b/app/Http/Controllers/Bo/AdviceController.php @@ -12,10 +12,11 @@ class AdviceController extends Controller /** * Show the form for editing the specified resource. * - * @param Advice $advice + * @param Advice $advice * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Advice $advice) { return view('back.advice.edit', compact('advice')); diff --git a/app/Http/Controllers/Bo/EncartsController.php b/app/Http/Controllers/Bo/EncartsController.php index 98867f1..f0c63c0 100644 --- a/app/Http/Controllers/Bo/EncartsController.php +++ b/app/Http/Controllers/Bo/EncartsController.php @@ -12,10 +12,11 @@ class EncartsController extends Controller /** * Show the form for editing the specified resource. * - * @param Encart $encart + * @param Encart $encart * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - //phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Encart $encart) { return view('back.encarts.edit', compact('encart')); diff --git a/app/Http/Controllers/Bo/GammesController.php b/app/Http/Controllers/Bo/GammesController.php index 403652d..6295de8 100644 --- a/app/Http/Controllers/Bo/GammesController.php +++ b/app/Http/Controllers/Bo/GammesController.php @@ -36,10 +36,12 @@ class GammesController extends Controller /** * Show the form for creating a new resource. * - * @param Gamme $gamme + * @param Gamme $gamme + * * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function create(Gamme $gamme) { $parentGammes = Gamme::whereNull('parent_gamme_id') @@ -53,7 +55,8 @@ class GammesController extends Controller * Store a newly created resource in storage. * * @param \Illuminate\Http\StoreGammeRequest $request - * @return \Illuminate\Http\Response + * + * @return \Illuminate\Http\RedirectResponse */ public function store(StoreGammeRequest $request) { @@ -74,10 +77,12 @@ class GammesController extends Controller /** * Show the form for editing the specified resource. * - * @param Gamme $gamme + * @param Gamme $gamme + * * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Gamme $gamme) { $parentGammes = Gamme::whereNull('parent_gamme_id') @@ -90,9 +95,10 @@ class GammesController extends Controller /** * Update the specified resource in storage. * - * @param \Illuminate\Http\UpdateGammeRequest $request * @param Gamme $gamme - * @return \Illuminate\Http\Response + * @param \Illuminate\Http\UpdateGammeRequest $request + * + * @return \Illuminate\Http\RedirectResponse */ public function update(Gamme $gamme, UpdateGammeRequest $request) { diff --git a/app/Http/Controllers/Bo/HomeController.php b/app/Http/Controllers/Bo/HomeController.php index e5dc521..962d39e 100644 --- a/app/Http/Controllers/Bo/HomeController.php +++ b/app/Http/Controllers/Bo/HomeController.php @@ -6,7 +6,11 @@ use App\Http\Controllers\Controller; class HomeController extends Controller { - // BO + /** + * BO Home View + * + * @return \Illuminate\Contracts\View\View + */ public function home() { return view('back.home'); diff --git a/app/Http/Controllers/Bo/MomentsController.php b/app/Http/Controllers/Bo/MomentsController.php index 7cae140..a927382 100644 --- a/app/Http/Controllers/Bo/MomentsController.php +++ b/app/Http/Controllers/Bo/MomentsController.php @@ -24,10 +24,11 @@ class MomentsController extends Controller /** * Show the form for editing the specified resource. * - * @param Moment $moment + * @param Moment $moment * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - //phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Moment $moment) { return view('back.moments.edit', compact('moment')); diff --git a/app/Http/Controllers/Bo/PictoBrandsController.php b/app/Http/Controllers/Bo/PictoBrandsController.php index 56a72a5..8da642d 100644 --- a/app/Http/Controllers/Bo/PictoBrandsController.php +++ b/app/Http/Controllers/Bo/PictoBrandsController.php @@ -25,10 +25,11 @@ class PictoBrandsController extends Controller /** * Show the form for creating a new resource. * - * @param PictoBrand $pictobrand + * @param PictoBrand $pictobrand * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function create(PictoBrand $pictobrand) { return view('back.pictobrands.create', compact('pictobrand')); @@ -58,10 +59,11 @@ class PictoBrandsController extends Controller /** * Show the form for editing the specified resource. * - * @param PictoBrand $pictobrand + * @param PictoBrand $pictobrand * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(PictoBrand $pictobrand) { return view('back.pictobrands.edit', compact('pictobrand')); diff --git a/app/Http/Controllers/Bo/PictosController.php b/app/Http/Controllers/Bo/PictosController.php index 22449d0..5ca867c 100644 --- a/app/Http/Controllers/Bo/PictosController.php +++ b/app/Http/Controllers/Bo/PictosController.php @@ -14,6 +14,8 @@ class PictosController extends Controller /** * Display a listing of the resource. * + * @param Page $page + * * @return \Illuminate\Http\Response */ public function index(Page $page) @@ -26,10 +28,11 @@ class PictosController extends Controller /** * Show the form for creating a new resource. * - * @param Picto $picto + * @param Picto $picto * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function create(Picto $picto) { return view('back.pictos.create', compact('picto')); @@ -47,8 +50,8 @@ class PictosController extends Controller if (is_a($request->picture, "SplFileInfo")) { $picto->picture = Utils::storeImage($request->picture, $picto->getTable()); } - // on ne peut pas arbitrairement créer tous les pictos à cet endroit - // j'ai du décommenter cette ligne pour la création picto fonctionne + // On ne peut pas arbitrairement créer tous les pictos à cet endroit. + // J'ai du décommenter cette ligne pour la création picto fonctionne. $picto->page = Page::marqueBloc2(); if (!$picto->saveOrFail()) { @@ -60,10 +63,11 @@ class PictosController extends Controller /** * Show the form for editing the specified resource. * - * @param Picto $picto + * @param Picto $picto * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Picto $picto) { return view('back.pictos.edit', compact('picto')); diff --git a/app/Http/Controllers/Bo/PostsController.php b/app/Http/Controllers/Bo/PostsController.php index 8241b7f..6219256 100644 --- a/app/Http/Controllers/Bo/PostsController.php +++ b/app/Http/Controllers/Bo/PostsController.php @@ -11,7 +11,7 @@ use App\Models\Post; class PostsController extends Controller { /** - * Display a listing of the resource. + * Display the posts view. * * @return \Illuminate\Http\Response */ @@ -25,10 +25,10 @@ class PostsController extends Controller /** * Show the form for creating a new resource. * - * @param Post $post + * @param Post $post * @return \Illuminate\Http\Response + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function create(Post $post) { return view('back.posts.create', compact('post')); @@ -63,10 +63,11 @@ class PostsController extends Controller /** * Show the form for editing the specified resource. * - * @param Post $post + * @param Post $post * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Post $post) { return view('back.posts.edit', compact('post')); @@ -75,8 +76,8 @@ class PostsController extends Controller /** * Update the specified resource in storage. * - * @param \Illuminate\Http\UpdatePostRequest $request * @param Post $post + * @param \Illuminate\Http\UpdatePostRequest $request * @return \Illuminate\Http\Response */ public function update(Post $post, UpdatePostRequest $request) diff --git a/app/Http/Controllers/Bo/ProductsController.php b/app/Http/Controllers/Bo/ProductsController.php index 00e73b6..1262a0b 100644 --- a/app/Http/Controllers/Bo/ProductsController.php +++ b/app/Http/Controllers/Bo/ProductsController.php @@ -26,14 +26,16 @@ class ProductsController extends Controller /** * Show the form for creating a new resource. * - * @param Product $product - * @return \Illuminate\Http\Response + * @param Product $product + * + * @return \Illuminate\Contracts\View\View + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function create(Product $product) { $gammes = Gamme::all()->sortBy('title'); - // default structure + produits + // Default structure + produits. $tabFour = array( 'id' => 0, 'name' => 'Four', @@ -162,10 +164,11 @@ class ProductsController extends Controller /** * Show the form for editing the specified resource. * - * @param Product $product + * @param Product $product * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Product $product) { $gammes = Gamme::all()->sortBy('title'); @@ -181,9 +184,9 @@ class ProductsController extends Controller */ public function update(Product $product, UpdateProductRequest $request) { - // valeurs en base pour garder les anciennes images quand elles ne sont pas updatées + // Valeurs en base pour garder les anciennes images quand elles ne sont pas updatées. $dbplusproduit = json_decode($product->plusproduit); - // valeurs transmises dans le post + // Valeurs transmises dans le post. $plusproduit = json_decode($request->plusproduit); $product->fill($request->validated()); if (is_a($request->picture, "SplFileInfo")) { @@ -191,20 +194,20 @@ class ProductsController extends Controller } foreach ($plusproduit as $plus) { - // boucle pour stockage des images uploadées + // Boucle pour stockage des images uploadées. $picto = 'pictogramme' . $plus->id; $uploadfile = $request->$picto; - // set de l'url + // Set de l'url. if ($uploadfile) { $plus->url = Utils::storeImage($uploadfile, $product->getTable()); } else { if (isset($dbplusproduit[$plus->id])) { - // reprise de l'ancienne valeur + // Reprise de l'ancienne valeur. $plus->url = $dbplusproduit[$plus->id]->url; } } } - // encodage avant save + // Encodage avant save. $product->plusproduit = json_encode($plusproduit); if (!$product->saveOrFail()) { return redirect()->route('bo.products.edit', $product->id) diff --git a/app/Http/Controllers/Bo/SeoDataController.php b/app/Http/Controllers/Bo/SeoDataController.php index 35e94b4..4ba9253 100644 --- a/app/Http/Controllers/Bo/SeoDataController.php +++ b/app/Http/Controllers/Bo/SeoDataController.php @@ -11,10 +11,11 @@ class SeoDataController extends Controller /** * Show the form for editing the specified resource. * - * @param \App\Models\SeoDatum $SeoDatum + * @param \App\Models\SeoDatum $SeoDatum * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - //phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(SeoDatum $SeoDatum) { return view('back.seo_data.edit', compact('SeoDatum')); diff --git a/app/Http/Controllers/Bo/SlidersController.php b/app/Http/Controllers/Bo/SlidersController.php index 31788ed..c9568dd 100644 --- a/app/Http/Controllers/Bo/SlidersController.php +++ b/app/Http/Controllers/Bo/SlidersController.php @@ -24,10 +24,11 @@ class SlidersController extends Controller /** * Show the form for creating a new resource. * - * @param Slider $slider + * @param Slider $slider * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - //phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function create(Slider $slider) { return view('back.sliders.create', compact('slider')); @@ -52,10 +53,11 @@ class SlidersController extends Controller /** * Show the form for editing the specified resource. * - * @param Slider $slider + * @param Slider $slider * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - //phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Slider $slider) { return view('back.sliders.edit', compact('slider')); diff --git a/app/Http/Controllers/Bo/SlidesController.php b/app/Http/Controllers/Bo/SlidesController.php index 94f8ad7..67a2d4e 100644 --- a/app/Http/Controllers/Bo/SlidesController.php +++ b/app/Http/Controllers/Bo/SlidesController.php @@ -25,10 +25,10 @@ class SlidesController extends Controller /** * Show the form for creating a new resource. * - * @param Slide $slide + * @param Slide $slide * @return \Illuminate\Http\Response + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function create(Slide $slide) { $sliders = Slider::all(); @@ -58,10 +58,10 @@ class SlidesController extends Controller /** * Show the form for editing the specified resource. * - * @param Slide $slide + * @param Slide $slide * @return \Illuminate\Http\Response + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Slide $slide) { $sliders = Slider::all(); @@ -105,7 +105,15 @@ class SlidesController extends Controller return redirect()->route('bo.slides.index')->with('success', trans('Suppression faite avec succès')); } - public function changeOrder(Slide $slide, $action) + /** + * change order for a slide + * + * @param Slide $slide + * @param string $action + * + * @return \Illuminate\Http\RedirectResponse + */ + public function changeOrder(Slide $slide, string $action) { if ($action === 'up') { $tmp = Slide::where('order', '<', $slide->order)->orderBy('order', 'DESC')->first(); @@ -126,6 +134,8 @@ class SlidesController extends Controller /** * retreive order position to put a new slide to + * + * @return integer */ private function getLastOrder() { diff --git a/app/Http/Controllers/Bo/TextsController.php b/app/Http/Controllers/Bo/TextsController.php index c47d9bc..5b85284 100644 --- a/app/Http/Controllers/Bo/TextsController.php +++ b/app/Http/Controllers/Bo/TextsController.php @@ -24,10 +24,11 @@ class TextsController extends Controller /** * Show the form for creating a new resource. * - * @param Text $text + * @param Text $text * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function create(Text $text) { return view('back.texts.create', compact('text')); @@ -57,10 +58,11 @@ class TextsController extends Controller /** * Show the form for editing the specified resource. * - * @param Text $text + * @param Text $text * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Text $text) { return view('back.texts.edit', compact('text')); @@ -69,8 +71,8 @@ class TextsController extends Controller /** * Update the specified resource in storage. * - * @param \Illuminate\Http\StoreTextRequest $request * @param Text $text + * @param \Illuminate\Http\StoreTextRequest $request * @return \Illuminate\Http\Response */ public function update(Text $text, StoreTextRequest $request) diff --git a/app/Http/Controllers/Bo/TitlesController.php b/app/Http/Controllers/Bo/TitlesController.php index c33a8fe..e75cded 100644 --- a/app/Http/Controllers/Bo/TitlesController.php +++ b/app/Http/Controllers/Bo/TitlesController.php @@ -11,10 +11,11 @@ class TitlesController extends Controller /** * Show the form for editing the specified resource. * - * @param Title $title + * @param Title $title * @return \Illuminate\Http\Response + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function edit(Title $title) { return view('back.titles.edit', compact('title')); diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index 265a09d..6f26c25 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -8,11 +8,22 @@ use Illuminate\Support\Facades\Mail; class ContactController extends Controller { + /** + * Show the contact view. + * + * @return \Illuminate\Contracts\View\View + */ public function contact() { return view('front.contact'); } + /** + * Send mail when submit the form. + * + * @param ContactFormRequest $request + * @return \Illuminate\Http\RedirectResponse + */ public function contactSubmit(ContactFormRequest $request) { Mail::to(config('mail.contactsList.contactform'))->send(new SendContactMail($request->validated())); diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 8d6c82b..8b05f8c 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -14,6 +14,9 @@ class Controller extends BaseController use DispatchesJobs; use ValidatesRequests; + /** + * Perform any actions required when creating the object. + */ public function __construct() { view()->share('availableCountries', Country::toArray()); diff --git a/app/Http/Controllers/FoodServiceController.php b/app/Http/Controllers/FoodServiceController.php index 7633f06..cf4d29a 100644 --- a/app/Http/Controllers/FoodServiceController.php +++ b/app/Http/Controllers/FoodServiceController.php @@ -11,6 +11,11 @@ use App\Models\Title; class FoodServiceController extends Controller { + /** + * Show the FoodService view. + * + * @return \Illuminate\Contracts\View\View + */ public function index() { $page = Page::foodservice(); diff --git a/app/Http/Controllers/GammesController.php b/app/Http/Controllers/GammesController.php index 5fc8fb2..1525d38 100644 --- a/app/Http/Controllers/GammesController.php +++ b/app/Http/Controllers/GammesController.php @@ -9,10 +9,15 @@ use App\Models\SeoDatum; class GammesController extends Controller { + /** + * Show the Gammes view. + * + * @return \Illuminate\Contracts\View\View + */ public function index() { $gammes = Gamme::whereNull('parent_gamme_id')->orderBy('title')->get(); - // remove Food Service from count + // Remove Food Service from count. /** @var \Illuminate\Database\Eloquent\Collection $gammes */ $gammes = $gammes->whereNotIn('slug', 'food-service'); $nb_gammes = $gammes->count(); @@ -23,6 +28,13 @@ class GammesController extends Controller return view('front.gammes.index', compact('gammes', 'nb_gammes', 'seoDatum')); } + /** + * Show one Gamme + * + * @param Gamme $gamme + * + * @return \Illuminate\Contracts\View\View + */ public function show(Gamme $gamme) { $gammes = collect([]); @@ -43,7 +55,7 @@ class GammesController extends Controller ->orderBy('name') ->get(); - // make ghost seoDatum from the gamme + // Make ghost seoDatum from the gamme. $seoDatum = new SeoDatum(); $seoDatum->title = $gamme->title; $seoDatum->description = $gamme->text; diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index f3807e7..fef0541 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -13,6 +13,11 @@ use Illuminate\Support\Carbon; class HomeController extends Controller { + /** + * Show the Homepage view. + * + * @return \Illuminate\Contracts\View\View + */ public function index() { @@ -46,7 +51,7 @@ class HomeController extends Controller ['date_end', '>', Carbon::now()->format('Y-m-d H:i:s')], ['on_top', true] ])->first(); - // Limitation à 3 produits affichés sur la homepage + // Limitation à 3 produits affichés sur la homepage. $products_home = Product::where('is_on_top', true)->take(3)->get(); return view('front.home', compact('slider', 'slides', 'seoDatum', 'encart_home', 'post_home', 'products_home')); diff --git a/app/Http/Controllers/LegalsController.php b/app/Http/Controllers/LegalsController.php index 120cfcd..a31bc1d 100644 --- a/app/Http/Controllers/LegalsController.php +++ b/app/Http/Controllers/LegalsController.php @@ -8,11 +8,16 @@ use App\Models\Text; class LegalsController extends Controller { + /** + * Show the legal disclaimer view. + * + * @return \Illuminate\Contracts\View\View + */ public function index() { $mentions_legales = Text::where('page', Page::mentions()->value)->first(); - // make ghost seoDatum from the gamme + // Make ghost seoDatum from the gamme. $seoDatum = new SeoDatum(); $seoDatum->title = $mentions_legales->title; diff --git a/app/Http/Controllers/MarqueController.php b/app/Http/Controllers/MarqueController.php index 2404ea5..4a63d5e 100644 --- a/app/Http/Controllers/MarqueController.php +++ b/app/Http/Controllers/MarqueController.php @@ -12,6 +12,11 @@ use App\Models\Title; class MarqueController extends Controller { + /** + * Show the Marque view. + * + * @return \Illuminate\Contracts\View\View + */ public function index() { $page = Page::marque(); diff --git a/app/Http/Controllers/NewsController.php b/app/Http/Controllers/NewsController.php index c95c65c..0d50c7b 100644 --- a/app/Http/Controllers/NewsController.php +++ b/app/Http/Controllers/NewsController.php @@ -13,6 +13,11 @@ use Illuminate\Support\Carbon; class NewsController extends Controller { + /** + * Show the News view. + * + * @return \Illuminate\Contracts\View\View + */ public function index() { $page = Page::news(); diff --git a/app/Http/Controllers/PolicyController.php b/app/Http/Controllers/PolicyController.php index 1ec4601..5a3ee59 100644 --- a/app/Http/Controllers/PolicyController.php +++ b/app/Http/Controllers/PolicyController.php @@ -8,11 +8,16 @@ use App\Models\Text; class PolicyController extends Controller { + /** + * Show the Privacy policy view. + * + * @return \Illuminate\Contracts\View\View + */ public function index() { $privacy_policy = Text::where('page', Page::charte()->value)->first(); - // make ghost seoDatum from the gamme + // Make ghost seoDatum from the gamme. $seoDatum = new SeoDatum(); $seoDatum->title = $privacy_policy->title; diff --git a/app/Http/Controllers/ProductsController.php b/app/Http/Controllers/ProductsController.php index be5558d..3984905 100644 --- a/app/Http/Controllers/ProductsController.php +++ b/app/Http/Controllers/ProductsController.php @@ -9,7 +9,14 @@ use Illuminate\Http\Request; class ProductsController extends Controller { - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed + /** + * Show one product + * + * @param Gamme $gamme + * @param Product $product + * @return \Illuminate\Contracts\View\View + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed + */ public function show(Gamme $gamme, Product $product) { $seoDatum = new SeoDatum(); @@ -19,6 +26,12 @@ class ProductsController extends Controller return view('front.product', compact('product', 'gamme', 'seoDatum')); } + /** + * Display a list of products resulting from search query + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Contracts\View\View + */ public function search(Request $request) { $filter = $request->query('filter'); diff --git a/app/Http/Controllers/TranslationController.php b/app/Http/Controllers/TranslationController.php deleted file mode 100644 index ab86e78..0000000 --- a/app/Http/Controllers/TranslationController.php +++ /dev/null @@ -1,23 +0,0 @@ -full() !== url()->previous()) { - return redirect()->back(); - } - return redirect()->route('home'); - } -} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 7ae6f2f..2299fc3 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -36,6 +36,7 @@ class Kernel extends HttpKernel \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, + 'lang-check', \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, ], diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index e7cc52d..ce0d636 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -14,6 +14,7 @@ namespace App\Http\Middleware; use Illuminate\Auth\Middleware\Authenticate as Middleware; +use Illuminate\Http\Request; /** * Undocumented class @@ -29,11 +30,10 @@ class Authenticate extends Middleware /** * Get the path the user should be redirected to when they are not authenticated. * - * @param \Illuminate\Http\Request $request La requête - * + * @param \Illuminate\Http\Request $request * @return string|null */ - protected function redirectTo($request) + protected function redirectTo(Request $request) { if (!$request->expectsJson()) { return route('bo.login'); diff --git a/app/Http/Middleware/BackEndGlobals.php b/app/Http/Middleware/BackEndGlobals.php index cddb249..03a39a3 100644 --- a/app/Http/Middleware/BackEndGlobals.php +++ b/app/Http/Middleware/BackEndGlobals.php @@ -17,8 +17,8 @@ class BackEndGlobals /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next + * @param \Illuminate\Http\Request $request + * @param \Closure(\Illuminate\Http\Request):(\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ public function handle(Request $request, Closure $next) diff --git a/app/Http/Middleware/FrontEndGlobals.php b/app/Http/Middleware/FrontEndGlobals.php index 20b80ed..a7c001d 100644 --- a/app/Http/Middleware/FrontEndGlobals.php +++ b/app/Http/Middleware/FrontEndGlobals.php @@ -4,21 +4,23 @@ namespace App\Http\Middleware; use Illuminate\Support\Facades\View; use Closure; +use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; +use Spatie\Translatable\HasTranslations; class FrontEndGlobals { /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next + * @param \Illuminate\Http\Request $request + * @param \Closure(\Illuminate\Http\Request):(\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ public function handle(Request $request, Closure $next) { - // header menu + // Header menu. $currentRoute = Route::current()->getName(); $routeParamsFR = Route::current()->parameters(); $routeParamsEN = $routeParamsFR; @@ -46,10 +48,21 @@ class FrontEndGlobals return $next($request); } - public function unbind(&$item, $k, $lang) + /** + * Switch locale for translatable models + * + * @param \Illuminate\Database\Eloquent\Model $item + * @param string $key + * @param string $locale + * @return void + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed + */ + private function unbind(Model &$item, string $key, string $locale) { - if ($k == 'gammeSlug' || $k == 'productSlug') { - $item = $item->getTranslation('slug', $lang); + // phpcs:enable + $classUses = class_uses($item); + if ($classUses and (\in_array(HasTranslations::class, $classUses))) { + $item = (clone $item)->setLocale($locale); } } } diff --git a/app/Http/Middleware/LangCheck.php b/app/Http/Middleware/LangCheck.php index 25eeac8..0fa7bd6 100644 --- a/app/Http/Middleware/LangCheck.php +++ b/app/Http/Middleware/LangCheck.php @@ -9,7 +9,13 @@ use Illuminate\Support\Facades\View; class LangCheck { + /** + * The available languages. + * + * @var array + */ protected $langs = ['fr','en','es']; + /** * Handle an incoming request. * @@ -22,24 +28,24 @@ class LangCheck $routName = $request->route()->getName(); if (preg_match('/^bo\./', $routName)) { - // Back office + // Back office. if ($request->lang) { - // within bo we set lang with querystring param + // Within bo we set lang with querystring param. $this->saveUserLocale($request->lang, $request); - // bonus remove lang parameter from query + // Bonus remove lang parameter from query. return redirect()->to($request->fullUrlWithoutQuery('lang')); } else { $this->checkFirstAccess($request); } } else { - // FRONT + // FRONT. if (preg_match('/^(en|es)\./', $routName)) { - // from front use named routes + // From front use named routes. $langset = $request->segment(1); $this->saveUserLocale($langset, $request); } else { - // not specified in route + // Not specified in route. if ($this->checkFirstAccess($request)) { $routNameEN = 'en.' . $routName; $routNameES = 'es.' . $routName; @@ -62,49 +68,56 @@ class LangCheck $sess_lang = $request->session()->get('lang', config('app.locale')); app()->setLocale($sess_lang); + config(['app.locale' => $sess_lang]); $routePrefixer = ""; if ($sess_lang != 'fr') { $routePrefixer = $sess_lang . '.'; } View::share('routeprefixer', $routePrefixer); - return $next($request); } /** + * Register Current user choice for language * + * @param string $lang + * @param \Illuminate\Http\Request $request + * + * @return void */ - private function saveUserLocale($lang, Request $request) + private function saveUserLocale(string $lang, Request $request) { - // Set cookie + // Set cookie. Cookie::queue(Cookie::forever('language', strtolower($lang))); - // set session + // Set session. $request->session()->put('lang', strtolower($lang)); } /** * checks if we have saved locale info for current user * if not find then save that locale + * @param \Illuminate\Http\Request $request + * * @return boolean */ private function checkFirstAccess(Request $request) { - // do we have session ? + // Do we have session ? if (!$request->session()->has('lang')) { $fromC = Cookie::get('language'); if (is_null($fromC) || empty($fromC)) { - // pas de cookie, recherche sur le navigateur + // Pas de cookie, recherche sur le navigateur. $fromC = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2); if (!in_array($fromC, $this->langs)) { - // default other languages to en + // Default other languages to en. $fromC = 'en'; } } $this->saveUserLocale($fromC, $request); return true; } - // we have lang session + // We have lang session. return false; } } diff --git a/app/Http/Requests/StorePostRequest.php b/app/Http/Requests/StorePostRequest.php index b89b81c..49f8324 100644 --- a/app/Http/Requests/StorePostRequest.php +++ b/app/Http/Requests/StorePostRequest.php @@ -5,6 +5,7 @@ namespace App\Http\Requests; use Carbon\Exceptions\InvalidFormatException; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Carbon; +use Illuminate\Validation\ValidationException; class StorePostRequest extends FormRequest { @@ -14,6 +15,18 @@ class StorePostRequest extends FormRequest * @return boolean */ public function authorize() + { + return auth()->check(); + } + + /** + * Prepare the data for validation. + * + * @return void + * + * @throws ValidationException When prepare merge fails to parse dates. + */ + protected function prepareForValidation() { try { $this->merge([ @@ -21,12 +34,13 @@ class StorePostRequest extends FormRequest 'date_end' => Carbon::parse("$this->date_end_date $this->date_end_time:00")->toDateTimeString(), 'on_top' => $this->on_top ? true : false, ]); - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch } catch (InvalidFormatException $e) { - // On fait rien + $error = ValidationException::withMessages([ + 'date_start_date' => ['Format de date incorrect'], + 'date_end_date' => ['Format de date incorrect'], + ]); + throw $error; } - - return auth()->check(); } /** diff --git a/app/Http/Requests/StoreProductRequest.php b/app/Http/Requests/StoreProductRequest.php index f99acd1..fe831dd 100644 --- a/app/Http/Requests/StoreProductRequest.php +++ b/app/Http/Requests/StoreProductRequest.php @@ -3,7 +3,6 @@ namespace App\Http\Requests; use App\Models\Gamme; -use Carbon\Exceptions\InvalidFormatException; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Str; @@ -23,142 +22,136 @@ class StoreProductRequest extends FormRequest * Prepare the data for validation. * * @return void + * @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh */ - //phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh protected function prepareForValidation() { - try { - $tabFour = array( - 'id' => 0, - 'name' => 'Four', - 'url' => '/assets/images/four.png', - 'time' => $this->time_cook0, - 'temp' => $this->temp_cook0, - 'status' => $this->is_activated0 ? true : false - ); - $tabFriteuse = array( - 'id' => 1, - 'name' => 'Friteuse', - 'url' => '/assets/images/friteuse.png', - 'time' => $this->time_cook1, - 'temp' => $this->temp_cook1, - 'status' => $this->is_activated1 ? true : false - ); - $tabPoele = array( - 'id' => 2, - 'name' => 'Poêle', - 'url' => '/assets/images/poele.png', - 'time' => $this->time_cook2, - 'temp' => $this->temp_cook2, - 'status' => $this->is_activated2 ? true : false - ); - $tabCocotte = array( - 'id' => 3, - 'name' => 'Cocotte', - 'url' => '/assets/images/cocotte.png', - 'time' => $this->time_cook3, - 'temp' => $this->temp_cook3, - 'status' => $this->is_activated3 ? true : false - ); - $tabPlancha = array( - 'id' => 4, - 'name' => 'Plancha', - 'url' => '/assets/images/plancha.png', - 'time' => $this->time_cook4, - 'temp' => $this->temp_cook4, - 'status' => $this->is_activated4 ? true : false - ); - $tabBainMarie = array( - 'id' => 5, - 'name' => 'Bain Marie', - 'url' => '/assets/images/bainmarie.png', - 'time' => $this->time_cook5, - 'temp' => $this->temp_cook5, - 'status' => $this->is_activated5 ? true : false - ); - $tabBarbecue = array( - 'id' => 6, - 'name' => 'Barbecue', - 'url' => '/assets/images/barbecue.png', - 'time' => $this->time_cook6, - 'temp' => $this->temp_cook6, - 'status' => $this->is_activated6 ? true : false - ); - $tabMicroOndes = array( - 'id' => 7, - 'name' => 'Micro Ondes', - 'url' => '/assets/images/micro-onde.png', - 'time' => $this->time_cook7, - 'temp' => $this->temp_cook7, - 'status' => $this->is_activated7 ? true : false - ); - $tabCasserole = array( - 'id' => 8, - 'name' => 'Casserole', - 'url' => '/assets/images/casserole.png', - 'time' => $this->time_cook8, - 'temp' => $this->temp_cook8, - 'status' => $this->is_activated8 ? true : false - ); - $tabCuisson = json_encode([ - 'four' => $tabFour, - 'friteuse' => $tabFriteuse, - 'poele' => $tabPoele, - 'cocotte' => $tabCocotte, - 'plancha' => $tabPlancha, - 'bainmarie' => $tabBainMarie, - 'barbecue' => $tabBarbecue, - 'microondes' => $tabMicroOndes, - 'casserole' => $tabCasserole - ]); + $tabFour = array( + 'id' => 0, + 'name' => 'Four', + 'url' => '/assets/images/four.png', + 'time' => $this->time_cook0, + 'temp' => $this->temp_cook0, + 'status' => $this->is_activated0 ? true : false + ); + $tabFriteuse = array( + 'id' => 1, + 'name' => 'Friteuse', + 'url' => '/assets/images/friteuse.png', + 'time' => $this->time_cook1, + 'temp' => $this->temp_cook1, + 'status' => $this->is_activated1 ? true : false + ); + $tabPoele = array( + 'id' => 2, + 'name' => 'Poêle', + 'url' => '/assets/images/poele.png', + 'time' => $this->time_cook2, + 'temp' => $this->temp_cook2, + 'status' => $this->is_activated2 ? true : false + ); + $tabCocotte = array( + 'id' => 3, + 'name' => 'Cocotte', + 'url' => '/assets/images/cocotte.png', + 'time' => $this->time_cook3, + 'temp' => $this->temp_cook3, + 'status' => $this->is_activated3 ? true : false + ); + $tabPlancha = array( + 'id' => 4, + 'name' => 'Plancha', + 'url' => '/assets/images/plancha.png', + 'time' => $this->time_cook4, + 'temp' => $this->temp_cook4, + 'status' => $this->is_activated4 ? true : false + ); + $tabBainMarie = array( + 'id' => 5, + 'name' => 'Bain Marie', + 'url' => '/assets/images/bainmarie.png', + 'time' => $this->time_cook5, + 'temp' => $this->temp_cook5, + 'status' => $this->is_activated5 ? true : false + ); + $tabBarbecue = array( + 'id' => 6, + 'name' => 'Barbecue', + 'url' => '/assets/images/barbecue.png', + 'time' => $this->time_cook6, + 'temp' => $this->temp_cook6, + 'status' => $this->is_activated6 ? true : false + ); + $tabMicroOndes = array( + 'id' => 7, + 'name' => 'Micro Ondes', + 'url' => '/assets/images/micro-onde.png', + 'time' => $this->time_cook7, + 'temp' => $this->temp_cook7, + 'status' => $this->is_activated7 ? true : false + ); + $tabCasserole = array( + 'id' => 8, + 'name' => 'Casserole', + 'url' => '/assets/images/casserole.png', + 'time' => $this->time_cook8, + 'temp' => $this->temp_cook8, + 'status' => $this->is_activated8 ? true : false + ); + $tabCuisson = json_encode([ + 'four' => $tabFour, + 'friteuse' => $tabFriteuse, + 'poele' => $tabPoele, + 'cocotte' => $tabCocotte, + 'plancha' => $tabPlancha, + 'bainmarie' => $tabBainMarie, + 'barbecue' => $tabBarbecue, + 'microondes' => $tabMicroOndes, + 'casserole' => $tabCasserole + ]); - $urlPlusProduit = ""; - if ($this->pictogramme0) { - $urlPlusProduit = "/assets/images/" . $this->pictogramme0->getClientOriginalName(); - } - $tabPlusProduit1 = array( - 'id' => 0, - 'name' => $this->content0, - 'url' => $urlPlusProduit, - ); - $urlPlusProduit = ""; - if ($this->pictogramme1) { - $urlPlusProduit = "/assets/images/" . $this->pictogramme1->getClientOriginalName(); - } - $tabPlusProduit2 = array( - 'id' => 1, - 'name' => $this->content1, - 'url' => $urlPlusProduit, - ); - $urlPlusProduit = ""; - if ($this->pictogramme2) { - $urlPlusProduit = "/assets/images/" . $this->pictogramme2->getClientOriginalName(); - } - $tabPlusProduit3 = array( - 'id' => 2, - 'name' => $this->content2, - 'url' => $urlPlusProduit, - ); - $tabPlusProduit = json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]); - - $this->merge([ - 'slug' => Str::slug($this->name), - 'gamme_id' => - $this->is_food_service ? - Gamme::where("slug->fr", "food-service")->firstOrFail()->id : - $this->gamme_id, - 'pictos' => $tabCuisson, - 'plusproduit' => $tabPlusProduit, - 'is_published' => $this->is_published ? true : false, - 'is_on_top' => $this->is_on_top ? true : false, - 'is_news' => $this->is_news ? true : false, - 'is_food_service' => $this->is_food_service ? true : false, - 'is_halal' => $this->is_halal ? true : false, - ]); - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch - } catch (InvalidFormatException $e) { - // On fait rien - }//end try + $urlPlusProduit = ""; + if ($this->pictogramme0) { + $urlPlusProduit = "/assets/images/" . $this->pictogramme0->getClientOriginalName(); + } + $tabPlusProduit1 = array( + 'id' => 0, + 'name' => $this->content0, + 'url' => $urlPlusProduit, + ); + $urlPlusProduit = ""; + if ($this->pictogramme1) { + $urlPlusProduit = "/assets/images/" . $this->pictogramme1->getClientOriginalName(); + } + $tabPlusProduit2 = array( + 'id' => 1, + 'name' => $this->content1, + 'url' => $urlPlusProduit, + ); + $urlPlusProduit = ""; + if ($this->pictogramme2) { + $urlPlusProduit = "/assets/images/" . $this->pictogramme2->getClientOriginalName(); + } + $tabPlusProduit3 = array( + 'id' => 2, + 'name' => $this->content2, + 'url' => $urlPlusProduit, + ); + $tabPlusProduit = json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]); + $this->merge([ + 'slug' => Str::slug($this->name), + 'gamme_id' => + $this->is_food_service ? + Gamme::where("slug->fr", "food-service")->firstOrFail()->id : + $this->gamme_id, + 'pictos' => $tabCuisson, + 'plusproduit' => $tabPlusProduit, + 'is_published' => $this->is_published ? true : false, + 'is_on_top' => $this->is_on_top ? true : false, + 'is_news' => $this->is_news ? true : false, + 'is_food_service' => $this->is_food_service ? true : false, + 'is_halal' => $this->is_halal ? true : false, + ]); } /** diff --git a/app/Http/Requests/StoreSlideRequest.php b/app/Http/Requests/StoreSlideRequest.php index a94bcf2..309b83e 100644 --- a/app/Http/Requests/StoreSlideRequest.php +++ b/app/Http/Requests/StoreSlideRequest.php @@ -22,6 +22,8 @@ class StoreSlideRequest extends FormRequest * Prepare the data for validation. * * @return void + * + * @throws ValidationException When prepare merge fails to parse dates. */ protected function prepareForValidation() { @@ -30,9 +32,12 @@ class StoreSlideRequest extends FormRequest 'date_start' => Carbon::parse("$this->date_start_date $this->date_start_time:00")->toDateTimeString(), 'date_end' => Carbon::parse("$this->date_end_date $this->date_end_time:00")->toDateTimeString(), ]); - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch } catch (InvalidFormatException $e) { - // On fait rien + $error = \Illuminate\Validation\ValidationException::withMessages([ + 'date_start_date' => ['Format de date incorrect'], + 'date_end_date' => ['Format de date incorrect'], + ]); + throw $error; } $this->merge([ 'title' => 'lorem title ' . rand(), diff --git a/app/Lib/Utils.php b/app/Lib/Utils.php index 19e6f97..5b87098 100644 --- a/app/Lib/Utils.php +++ b/app/Lib/Utils.php @@ -23,6 +23,9 @@ class Utils * @param \Illuminate\Http\UploadedFile|\SplFileInfo|string $image * @param string $folderName * @return string The storage path + * + * @throws \ErrorException If file copy fails. + * @throws Exception If didn't manage to return a file path. */ public static function storeImage($image, string $folderName): string { @@ -39,7 +42,7 @@ class Utils $image = $image; $newPath = self::prepareMoveFile($image->getBaseName(), $folderName); if (!File::copy($image->getRealPath(), $newPath)) { - throw new \Exception(sprintf( + throw new \ErrorException(sprintf( 'Failed to copy file %s to %s', $image->getRealPath(), $newPath @@ -52,6 +55,15 @@ class Utils } throw new Exception(sprintf('Cannot handle image %s', \gettype($image))); } + + /** + * Prepare storage path and return + * the image full path + * + * @param string $filename The basename for the file. + * @param string $folderName Foldername for storage. + * @return string + */ private static function prepareMoveFile(string $filename, string $folderName): string { $pathFolder = \storage_path("app/public/images/$folderName"); diff --git a/app/Mail/SendContactMail.php b/app/Mail/SendContactMail.php index abfdc38..794c86c 100644 --- a/app/Mail/SendContactMail.php +++ b/app/Mail/SendContactMail.php @@ -33,6 +33,8 @@ class SendContactMail extends Mailable /** * The form data. + * + * @var array */ protected $data; @@ -47,9 +49,11 @@ class SendContactMail extends Mailable /** * Create a new message instance. * + * @param array $data + * * @return void */ - public function __construct($data) + public function __construct(array $data) { $this->data = $data; } diff --git a/app/Models/Advice.php b/app/Models/Advice.php index dd4bb3f..4313c19 100644 --- a/app/Models/Advice.php +++ b/app/Models/Advice.php @@ -13,6 +13,11 @@ class Advice extends Model use HasFactory; use HasTranslations; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'title1', 'title2', @@ -26,6 +31,11 @@ class Advice extends Model 'text2', ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'title1', 'title2', @@ -39,7 +49,12 @@ class Advice extends Model 'text2', ]; - //phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh + /** + * Perform any actions required after the model boots. + * + * @return void + * @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh + */ protected static function boot() { static::creating(function (Advice $advice) { diff --git a/app/Models/Encart.php b/app/Models/Encart.php index 4dd8794..1ea0d58 100644 --- a/app/Models/Encart.php +++ b/app/Models/Encart.php @@ -14,10 +14,20 @@ class Encart extends Model use HasFactory; use CastsEnumsHasTranslations; + /** + * Map attribute names to enum classes. + * + * @var array + */ public $enumCasts = [ 'page' => Page::class ]; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'title', 'subtitle', @@ -26,6 +36,11 @@ class Encart extends Model 'alt_text_picture', ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'title', 'subtitle', @@ -34,6 +49,11 @@ class Encart extends Model 'alt_text_picture', ]; + /** + * Perform any actions required after the model boots. + * + * @return void + */ protected static function boot() { static::creating(function (Encart $encart) { diff --git a/app/Models/Gamme.php b/app/Models/Gamme.php index 3a68dd7..d0ab6b0 100644 --- a/app/Models/Gamme.php +++ b/app/Models/Gamme.php @@ -13,6 +13,11 @@ class Gamme extends Model use HasFactory; use HasTranslations; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'parent_gamme_id', 'title', @@ -25,6 +30,11 @@ class Gamme extends Model 'alt_text_banner', ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'title', 'slug', @@ -35,7 +45,12 @@ class Gamme extends Model 'alt_text_banner', ]; - //phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh + /** + * Perform any actions required after the model boots. + * + * @return void + * @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh + */ protected static function boot() { static::creating(function (Gamme $gamme) { @@ -47,7 +62,7 @@ class Gamme extends Model } if ($gamme->parent_gamme_id != null) { - // Si Creation gamme enfant sans enfant, alors il faut update sa couleur selon celle du parent + // Si Creation gamme enfant sans enfant, alors il faut update sa couleur selon celle du parent. $gamme->color = Gamme::whereId($gamme->parent_gamme_id)->select(['color'])->first()->color; } }); @@ -60,7 +75,7 @@ class Gamme extends Model $gamme->banner = Utils::storeImage($gamme->banner, $gamme->getTable()); } if ($gamme->parent_gamme_id === null) { - // Si Update gamme parente, alors il faut update la couleur des enfants + // Si Update gamme parente, alors il faut update la couleur des enfants. Gamme::whereParentGammeId($gamme->id) ->update(['color' => $gamme->color]); } elseif ($gamme->childGammes()->exists()) { @@ -73,7 +88,7 @@ class Gamme extends Model Gamme::whereParentGammeId($gamme->id) ->update(['parent_gamme_id' => null]); } else { - // Si Update gamme enfant sans enfant, alors il faut update sa couleur selon celle du parent + // Si Update gamme enfant sans enfant, alors il faut update sa couleur selon celle du parent. $gamme->color = Gamme::whereId($gamme->parent_gamme_id)->select(['color'])->first()->color; } }); @@ -106,6 +121,11 @@ class Gamme extends Model parent::boot(); } + /** + * map hex color notation to rgba() syntax + * + * @return string + */ public function getRgbaColorAttribute() { $color = $this->color; @@ -121,11 +141,21 @@ class Gamme extends Model return "rgba($r,$g,$b,1)"; } + /** + * HasMany childGammes relation + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ public function childGammes() { return $this->hasMany(Gamme::class, 'parent_gamme_id'); } + /** + * BelongsTo parentGamme relation + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function parentGamme() { return $this->belongsTo(Gamme::class); @@ -133,6 +163,9 @@ class Gamme extends Model /** * Get Products for the Range. + * HasMany products relation + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function products() { diff --git a/app/Models/Moment.php b/app/Models/Moment.php index c474cde..aa7008b 100644 --- a/app/Models/Moment.php +++ b/app/Models/Moment.php @@ -14,10 +14,20 @@ class Moment extends Model use HasFactory; use CastsEnumsHasTranslations; + /** + * Map attribute names to enum classes. + * + * @var array + */ public $enumCasts = [ 'page' => Page::class ]; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'title', 'subtitle', @@ -26,6 +36,11 @@ class Moment extends Model 'alt_text_picture', ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'title', 'subtitle', @@ -34,6 +49,11 @@ class Moment extends Model 'alt_text_picture', ]; + /** + * Perform any actions required after the model boots. + * + * @return void + */ protected static function boot() { static::creating(function (Moment $moment) { diff --git a/app/Models/Picto.php b/app/Models/Picto.php index 70adefc..98d606b 100644 --- a/app/Models/Picto.php +++ b/app/Models/Picto.php @@ -14,22 +14,42 @@ class Picto extends Model use HasFactory; use CastsEnumsHasTranslations; + /** + * Map attribute names to enum classes. + * + * @var array + */ public $enumCasts = [ 'page' => Page::class ]; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'picture', 'alt_text_picture', 'text', ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'picture', 'alt_text_picture', 'text', ]; + /** + * Perform any actions required after the model boots. + * + * @return void + */ protected static function boot() { static::creating(function (Picto $picto) { diff --git a/app/Models/PictoBrand.php b/app/Models/PictoBrand.php index bb08aba..c6eafd8 100644 --- a/app/Models/PictoBrand.php +++ b/app/Models/PictoBrand.php @@ -13,6 +13,11 @@ class PictoBrand extends Model use HasFactory; use HasTranslations; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'title', 'picture', @@ -20,6 +25,11 @@ class PictoBrand extends Model 'text', ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'title', 'picture', @@ -27,6 +37,11 @@ class PictoBrand extends Model 'text', ]; + /** + * Perform any actions required after the model boots. + * + * @return void + */ protected static function boot() { static::creating(function (PictoBrand $pictoBrand) { diff --git a/app/Models/Post.php b/app/Models/Post.php index caf4a5b..00903d6 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -23,6 +23,11 @@ class Post extends Model 'date_end' => 'datetime', ]; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'title', 'text', @@ -35,6 +40,11 @@ class Post extends Model 'on_top' ]; + /** + * The attributes that are translatable. + * + * @var array + */ protected $translatable = [ 'title', 'text', @@ -44,7 +54,12 @@ class Post extends Model 'alt_text_picture_news' ]; - //phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh + /** + * Perform any actions required after the model boots. + * + * @return void + * @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh + */ protected static function boot() { static::creating(function (Post $post) { diff --git a/app/Models/Product.php b/app/Models/Product.php index e1d8429..e687e93 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -13,6 +13,11 @@ class Product extends Model use HasFactory; use HasTranslations; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'gamme_id', 'name', @@ -31,6 +36,11 @@ class Product extends Model 'seo_description', ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'name', 'slug', @@ -43,6 +53,11 @@ class Product extends Model 'seo_description', ]; + /** + * Perform any actions required after the model boots. + * + * @return void + */ protected static function boot() { static::creating(function (Product $product) { @@ -66,7 +81,7 @@ class Product extends Model } } } - // delete des images de plus produit + // Delete des images de plus produit. $plusproduit = json_decode($product->plusproduit); foreach ($plusproduit as $plus) { $urlPicture = public_path() . $plus->url; @@ -82,6 +97,8 @@ class Product extends Model /** * Get the Range that owns the product. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function gamme() { diff --git a/app/Models/SeoDatum.php b/app/Models/SeoDatum.php index b6c48be..5efb675 100644 --- a/app/Models/SeoDatum.php +++ b/app/Models/SeoDatum.php @@ -12,6 +12,11 @@ class SeoDatum extends Model use HasFactory; use CastsEnumsHasTranslations; + /** + * Map attribute names to enum classes. + * + * @var array + */ public $enumCasts = [ 'page' => Page::class ]; @@ -47,4 +52,35 @@ class SeoDatum extends Model { return 'page'; } + + /** + * Get Generic attribute value + * + * @param mixed $key + * @return mixed + */ + public function getAttributeValue($key) + { + if ($this->hasEnumCast($key)) { + $value = parent::getAttributeValue($key); + return $this->castToEnum($key, $value); + } + + return $this->TransGetAttributeValue($key); + } + + /** + * Set a given attribute on the model. + * + * @param mixed $key + * @param mixed $value + * @return mixed + */ + public function setAttribute($key, $value) + { + if ($this->hasEnumCast($key)) { + return $this->EnumSetAttribute($key, $value); + } + return $this->TransSetAttribute($key, $value); + } } diff --git a/app/Models/Slide.php b/app/Models/Slide.php index 8fc4c75..86687b0 100644 --- a/app/Models/Slide.php +++ b/app/Models/Slide.php @@ -23,6 +23,11 @@ class Slide extends Model 'date_end' => 'datetime', ]; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'title', 'text', @@ -36,6 +41,11 @@ class Slide extends Model 'date_end' ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'title', 'text', @@ -45,6 +55,11 @@ class Slide extends Model 'alt_text_picture' ]; + /** + * Perform any actions required after the model boots. + * + * @return void + */ protected static function boot() { static::creating(function (Slide $slide) { @@ -72,6 +87,11 @@ class Slide extends Model parent::boot(); } + /** + * BelongsTo slider relation + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function slider() { return $this->belongsTo(Slider::class); diff --git a/app/Models/Slider.php b/app/Models/Slider.php index 557d28d..260c0a0 100644 --- a/app/Models/Slider.php +++ b/app/Models/Slider.php @@ -12,6 +12,11 @@ class Slider extends Model use HasFactory; use HasTranslations; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'label', 'slug', @@ -19,17 +24,32 @@ class Slider extends Model 'published' ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'label', 'slug', 'commentaire' ]; + /** + * HasMany slides relation + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ public function slides() { return $this->hasMany(Slide::class, 'slider_id')->orderBy('order', 'ASC'); } + /** + * HasMany showable slides relation + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ public function showableSlides() { $now = Carbon::now(); diff --git a/app/Models/Text.php b/app/Models/Text.php index 65cc06a..86f227f 100644 --- a/app/Models/Text.php +++ b/app/Models/Text.php @@ -3,24 +3,41 @@ namespace App\Models; use App\Enums\Page; -use App\Traits\CastsEnumsHasTranslations; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Kwaadpepper\Enum\Traits\CastsEnums; +use Spatie\Translatable\HasTranslations; class Text extends Model { use HasFactory; - use CastsEnumsHasTranslations; + use CastsEnums; + use HasTranslations; + /** + * Map attribute names to enum classes. + * + * @var array + */ public $enumCasts = [ 'page' => Page::class ]; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'title', 'text', ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'title', 'text', diff --git a/app/Models/Title.php b/app/Models/Title.php index 18ca140..0288d7d 100644 --- a/app/Models/Title.php +++ b/app/Models/Title.php @@ -12,15 +12,30 @@ class Title extends Model use HasFactory; use CastsEnumsHasTranslations; + /** + * Map attribute names to enum classes. + * + * @var array + */ public $enumCasts = [ 'page' => Page::class ]; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'title', 'text', ]; + /** + * The attributes that are translatable. + * + * @var array + */ public $translatable = [ 'title', 'text', diff --git a/app/Models/User.php b/app/Models/User.php index e239721..d1fc5a7 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -15,6 +15,11 @@ class User extends Authenticatable use Notifiable; use CastsEnums; + /** + * Map attribute names to enum classes. + * + * @var array + */ public $enumCasts = [ 'role' => Role::class ]; @@ -49,6 +54,11 @@ class User extends Authenticatable 'email_verified_at' => 'datetime', ]; + /** + * Perform any actions required after the model boots. + * + * @return void + */ protected static function boot() { static::creating(function (User $user) { diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 35524d3..a518879 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -4,6 +4,7 @@ namespace App\Providers; use App\Models\Gamme; use App\Models\Product; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Route; @@ -31,18 +32,45 @@ class RouteServiceProvider extends ServiceProvider ->group(base_path('routes/web.php')); }); - //phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed - Route::bind('gammeSlug', function ($value, $route) { - $gamme = Gamme::where('slug', 'LIKE', '%:"' . $value . '"%')->firstOrFail(); - return $gamme; + Route::bind('gammeSlug', function ($value) { + /** @var string $locale @var string $defaultLocale @var string $value */ + $vars = $this->getRouteBinderVars($value); + \extract($vars); + /** @var \App\Models\Gamme */ + $gamme = Gamme::where(function (Builder $q) use ($locale, $defaultLocale, $value) { + $q->whereRaw("JSON_EXTRACT(slug, '$.$locale') = '$value'") + ->orWhereRaw("JSON_EXTRACT(slug, '$.$defaultLocale') = '$value'"); + })->firstOrFail(); + return $gamme->setLocale($locale); }); Route::bind('productSlug', function ($value, $route) { - $gamme = $route->parameter('gammeSlug'); - $product = Product::where('slug', 'LIKE', '%:"' . $value . '"%') - ->where('gamme_id', $gamme->id) - ->firstOrFail(); - return $product; + /** @var \Illuminate\Routing\Route $route */ + $gamme = $route->parameter('gammeSlug'); + + /** @var string $locale @var string $defaultLocale @var string $value */ + $vars = $this->getRouteBinderVars($value); + \extract($vars); + /** @var \App\Models\Product */ + $product = Product::where(function (Builder $q) use ($locale, $defaultLocale, $value) { + $q->whereRaw("JSON_EXTRACT(slug, '$.$locale') = '$value'") + ->orWhereRaw("JSON_EXTRACT(slug, '$.$defaultLocale') = '$value'"); + })->where('gamme_id', $gamme->id) + ->firstOrFail(); + return $product->setLocale($locale); }); } + + /** + * Get route binder common + * @param string $value + * @return string[] + */ + private function getRouteBinderVars(string $value): array + { + $locale = \app()->getLocale(); + $defaultLocale = \config('translatable.fallback_locale'); + $value = \filter_var($value, \FILTER_SANITIZE_STRING); + return compact('locale', 'defaultLocale', 'value'); + } } diff --git a/app/Traits/CastsEnumsHasTranslations.php b/app/Traits/CastsEnumsHasTranslations.php index 9975e38..5682eea 100644 --- a/app/Traits/CastsEnumsHasTranslations.php +++ b/app/Traits/CastsEnumsHasTranslations.php @@ -16,6 +16,10 @@ trait CastsEnumsHasTranslations /** * Manually mix getAttributeValue from CastsEnums and HasTranslations + * + * @param mixed $key + * + * @return string */ public function getAttributeValue($key) { @@ -28,6 +32,11 @@ trait CastsEnumsHasTranslations /** * Manually mix setAttribute from CastsEnums and HasTranslations + * + * @param mixed $key + * @param mixed $value + * + * @return mixed */ public function setAttribute($key, $value) { diff --git a/config/app.php b/config/app.php index 4b4ebd9..08fee42 100644 --- a/config/app.php +++ b/config/app.php @@ -139,6 +139,7 @@ return [ /* * Laravel Framework Service Providers... */ + Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, @@ -169,6 +170,7 @@ return [ /* * Application Service Providers... */ + App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, App\Providers\EventServiceProvider::class, @@ -227,7 +229,7 @@ return [ 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, - // Enums + // Enums. 'Page' => \App\Enums\Page::class, ], diff --git a/config/bo.php b/config/bo.php index b1149ab..a061aed 100644 --- a/config/bo.php +++ b/config/bo.php @@ -1,6 +1,7 @@ env('MAIL_FROM_NAME', 'Example'), ], - // Contacts List + // Contacts List. 'contactsList' => [ 'contactform' => explode(",", env('MAIL_LIST_CONTACTFORM', 'equipe.web@ldc.fr')) ], diff --git a/config/purifier.php b/config/purifier.php index a86a47c..d0efb83 100644 --- a/config/purifier.php +++ b/config/purifier.php @@ -26,7 +26,7 @@ return [ 'settings' => [ 'default' => [ 'HTML.SafeIframe' => true, -// For iframes +// For iframes. 'URI.SafeIframeRegexp' => "%^(http://|https://|//)(vimeo.com)%", 'HTML.Doctype' => 'HTML 4.01 Transitional', 'HTML.Allowed' => 'h1[style],h2[style],h3[style],h4[style],h5[style],h6[style],figure[class],oembed[url],div,b,strong,i,em,u,a[href|title],ul[style],ol[style],dl[style],li,p[style],br,span[style|class],img[width|height|alt|src],iframe[src|width|height|class|frameborder],table,thead,tbody,th,tr,td,hr', @@ -44,7 +44,7 @@ return [ 'rev' => 1, 'debug' => true, 'elements' => [ - // http://developers.whatwg.org/sections.html + // See : http://developers.whatwg.org/sections.html . ['section', 'Block', 'Flow', 'Common'], ['nav', 'Block', 'Flow', 'Common'], ['article', 'Block', 'Flow', 'Common'], @@ -52,16 +52,16 @@ return [ ['header', 'Block', 'Flow', 'Common'], ['footer', 'Block', 'Flow', 'Common'], - // Content model actually excludes several tags, not modelled here + // Content model actually excludes several tags, not modelled here. ['address', 'Block', 'Flow', 'Common'], ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'], - // http://developers.whatwg.org/grouping-content.html + // See : http://developers.whatwg.org/grouping-content.html . ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'], ['figcaption', 'Inline', 'Flow', 'Common'], ['oembed', 'Inline', 'Flow', 'Common'], - // http://developers.whatwg.org/the-video-element.html#the-video-element + // See : http://developers.whatwg.org/the-video-element.html#the-video-element . ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', @@ -76,7 +76,7 @@ return [ 'type' => 'Text', ]], - // http://developers.whatwg.org/text-level-semantics.html + // See : http://developers.whatwg.org/text-level-semantics.html . ['s', 'Inline', 'Inline', 'Common'], ['var', 'Inline', 'Inline', 'Common'], ['sub', 'Inline', 'Inline', 'Common'], @@ -84,7 +84,7 @@ return [ ['mark', 'Inline', 'Inline', 'Common'], ['wbr', 'Inline', 'Empty', 'Core'], - // http://developers.whatwg.org/edits.html + // See : http://developers.whatwg.org/edits.html . ['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']], ['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']], ], diff --git a/config/translatable.php b/config/translatable.php new file mode 100644 index 0000000..e3040c2 --- /dev/null +++ b/config/translatable.php @@ -0,0 +1,12 @@ + 'fr', +]; diff --git a/config/translation.php b/config/translation.php index b2a2b29..727575b 100644 --- a/config/translation.php +++ b/config/translation.php @@ -1,6 +1,7 @@ 'database', /* @@ -22,6 +24,7 @@ return [ | configuration here to configure the routes with your preferred group options. | */ + 'route_group_config' => [ 'middleware' => [ 'web', @@ -38,6 +41,7 @@ return [ | when finding missing translations. | */ + 'translation_methods' => ['trans', '__'], /* @@ -49,6 +53,7 @@ return [ | looking for missing translations. | */ + 'scan_paths' => [ resource_path() . '/views/front', resource_path() . '/views/layouts/frontend', @@ -62,6 +67,7 @@ return [ | Define the URL used to access the language management too. | */ + 'ui_url' => 'bo/languages', /* @@ -72,6 +78,7 @@ return [ | Define the settings for the database driver here. | */ + 'database' => [ 'connection' => '', diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 8a63f40..d24a902 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -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), ]; } diff --git a/routes/web.php b/routes/web.php index fefef40..56f6697 100644 --- a/routes/web.php +++ b/routes/web.php @@ -61,14 +61,14 @@ Route::prefix('bo') 'logout' => true, 'register' => false, 'reset' => false, - // for resetting passwords + // For resetting passwords. 'confirm' => false, - // for additional password confirmations + // For additional password confirmations. 'verify' => false, - // for email verification + // For email verification. ] ); - Route::middleware(['auth:web', 'back-end-globals', 'lang-check']) + Route::middleware(['auth:web', 'back-end-globals']) ->group( function () { Route::get( @@ -117,29 +117,55 @@ Route::prefix('bo') $langs = ['en', 'es', '']; foreach ($langs as $lang) { - Route::middleware(['front-end-globals', 'lang-check']) + Route::middleware(['front-end-globals']) ->prefix($lang) ->name($lang == '' ? '' : $lang . '.') ->group( function () use ($lang) { Route::get('/', [ControllersHomeController::class, 'index'])->name('home'); - // phpcs:disable Generic.Files.LineLength.TooLong - Route::get('/' . Str::slug(Lang::get('urls.marque', [], $lang)), [ControllersMarqueController::class, 'index'])->name('wasup'); - Route::get('/' . Str::slug(Lang::get('urls.gammes', [], $lang)), [ControllersGammesController::class, 'index'])->name('gammes.index'); - Route::get('/' . Str::slug(Lang::get('urls.gamme', [], $lang)) . '/{gammeSlug}', [ControllersGammesController::class, 'show'])->name('gammes.show'); + Route::get( - '/' . Str::slug(Lang::get('urls.produit', [], $lang)) . '/{gammeSlug}/{productSlug}', + '/' . Str::slug(Lang::get('urls.marque', [], $lang)), + [ControllersMarqueController::class, 'index'] + )->name('wasup'); + Route::get( + '/' . Str::slug(Lang::get('urls.gammes', [], $lang)), + [ControllersGammesController::class, 'index'] + )->name('gammes.index'); + Route::get( + '/' . Str::slug(Lang::get('urls.gamme', [], $lang)) . '/{gammeSlug:slug}', + [ControllersGammesController::class, 'show'] + )->name('gammes.show'); + Route::get( + '/' . Str::slug(Lang::get('urls.produit', [], $lang)) . '/{gammeSlug:slug}/{productSlug:slug}', [ControllersProductsController::class, 'show'] )->name('product.show'); - Route::get('/' . Str::slug(Lang::get('urls.news', [], $lang)), [ControllersNewsController::class, 'index'])->name('news'); - Route::get('/' . Str::slug(Lang::get('urls.food-service', [], $lang)), [ControllersFoodServiceController::class, 'index'])->name('food'); - Route::get('/' . Str::slug(Lang::get('urls.legals', [], $lang)), [ControllersLegalsController::class, 'index'])->name('cgu'); - Route::get('/' . Str::slug(Lang::get('urls.policy', [], $lang)), [ControllersPolicyController::class, 'index'])->name('policy'); - Route::get('/' . Str::slug(Lang::get('urls.search', [], $lang)), [ControllersProductsController::class, 'search'])->name('search'); - // Classic - Route::get('/' . Str::slug(Lang::get('urls.contact', [], $lang)), [ControllersContactController::class, 'contact'])->name('contact'); + Route::get( + '/' . Str::slug(Lang::get('urls.news', [], $lang)), + [ControllersNewsController::class, 'index'] + )->name('news'); + Route::get( + '/' . Str::slug(Lang::get('urls.food-service', [], $lang)), + [ControllersFoodServiceController::class, 'index'] + )->name('food'); + Route::get( + '/' . Str::slug(Lang::get('urls.legals', [], $lang)), + [ControllersLegalsController::class, 'index'] + )->name('cgu'); + Route::get( + '/' . Str::slug(Lang::get('urls.policy', [], $lang)), + [ControllersPolicyController::class, 'index'] + )->name('policy'); + Route::get( + '/' . Str::slug(Lang::get('urls.search', [], $lang)), + [ControllersProductsController::class, 'search'] + )->name('search'); + // Classic. + Route::get( + '/' . Str::slug(Lang::get('urls.contact', [], $lang)), + [ControllersContactController::class, 'contact'] + )->name('contact'); Route::post('/contact', [ControllersContactController::class, 'contactSubmit'])->name('contact.submit'); - // phpcs:enable } ); }//end foreach