From 5d68e8787ac5b9798128a423c694539728f677ff Mon Sep 17 00:00:00 2001 From: Ludovic CANDELLIER Date: Sun, 24 Apr 2022 22:07:31 +0200 Subject: [PATCH] 'fixes' --- .../Controllers/Shop/Auth/LoginController.php | 5 +- .../Shop/Auth/RegisterController.php | 3 +- .../Shop/Auth/ResetPasswordController.php | 1 - app/Repositories/Core/Auth/Users.php | 1 + app/Repositories/Shop/Customers.php | 30 +++++ app/Repositories/Shop/Offers.php | 2 +- .../Articles/partials/addBasket.blade.php | 4 +- resources/views/Shop/auth/register.blade.php | 116 ++++++++++++++---- .../layout/partials/header-profile.blade.php | 6 +- .../Shop/layout/partials/sections.blade.php | 22 ++-- .../views/auth/passwords/reset.blade.php | 2 +- 11 files changed, 147 insertions(+), 45 deletions(-) diff --git a/app/Http/Controllers/Shop/Auth/LoginController.php b/app/Http/Controllers/Shop/Auth/LoginController.php index 73d34da5..5226dea8 100644 --- a/app/Http/Controllers/Shop/Auth/LoginController.php +++ b/app/Http/Controllers/Shop/Auth/LoginController.php @@ -31,12 +31,13 @@ class LoginController extends Controller public function login(Request $request) { - $this->validate($request, [ + $credentials = $request->validate([ 'email' => 'required|email', 'password' => 'required|min:8', ]); - if (Auth::guard('customer')->attempt(['email' => $request->email, 'password' => $request->password], $request->get('remember'))) { + if (Auth::guard('customer')->attempt($credentials, $request->get('remember'))) { + $request->session()->regenerate(); return redirect()->intended(route('home')); } return back()->withInput($request->only('email', 'remember')); diff --git a/app/Http/Controllers/Shop/Auth/RegisterController.php b/app/Http/Controllers/Shop/Auth/RegisterController.php index dafc9f4b..d52c2d54 100644 --- a/app/Http/Controllers/Shop/Auth/RegisterController.php +++ b/app/Http/Controllers/Shop/Auth/RegisterController.php @@ -46,7 +46,8 @@ class RegisterController extends Controller public function showRegistrationForm() { - return view('Shop.auth.register'); + $data = self::init(); + return view('Shop.auth.register', $data ?? []); } protected function create(array $data) diff --git a/app/Http/Controllers/Shop/Auth/ResetPasswordController.php b/app/Http/Controllers/Shop/Auth/ResetPasswordController.php index e43179b8..2cf76c69 100644 --- a/app/Http/Controllers/Shop/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Shop/Auth/ResetPasswordController.php @@ -19,7 +19,6 @@ class ResetPasswordController extends Controller public function showResetForm(Request $request, $token = null) { - $data = $this->initHeader(); $data['token'] = $token; $data['email'] = $request->email; return view('Auth.passwords.reset', $data); diff --git a/app/Repositories/Core/Auth/Users.php b/app/Repositories/Core/Auth/Users.php index 9b7407d4..cf4d0741 100644 --- a/app/Repositories/Core/Auth/Users.php +++ b/app/Repositories/Core/Auth/Users.php @@ -18,6 +18,7 @@ use App\Repositories\Partners; use App\Repositories\Core\Upload; use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules; + class Users { use LaratrustUserTrait; diff --git a/app/Repositories/Shop/Customers.php b/app/Repositories/Shop/Customers.php index 8a0a84df..d7c0f066 100644 --- a/app/Repositories/Shop/Customers.php +++ b/app/Repositories/Shop/Customers.php @@ -2,10 +2,40 @@ namespace App\Repositories\Shop; +use Illuminate\Support\Facades\Auth; + + use App\Models\Shop\Customer; class Customers { + + public static function getAvatar() + { + + } + + public static function getName() + { + $user = self::getAuth(); + return $user ? $user->first_name : ''; + } + + public static function getAuth() + { + return Auth::guard('customer')->user(); + } + + public static function getId() + { + return Auth::guard('customer')->id(); + } + + public static function isConnected() + { + return Auth::guard('customer')->check(); + } + public static function getOptions() { return Customer::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray(); diff --git a/app/Repositories/Shop/Offers.php b/app/Repositories/Shop/Offers.php index 9be59e1c..980b681a 100644 --- a/app/Repositories/Shop/Offers.php +++ b/app/Repositories/Shop/Offers.php @@ -40,7 +40,7 @@ class Offers { $sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID(); $offer = Offer::withPriceBySaleChannelByQuantity($sale_channel_id, $quantity)->find($id); - return number_format($offer->price_lists->first()->price_list_values->first(),2); + return $offer->price_lists->first()->price_list_values->first(); } public static function getBasket() diff --git a/resources/views/Shop/Articles/partials/addBasket.blade.php b/resources/views/Shop/Articles/partials/addBasket.blade.php index bab98c5c..ad4426b8 100644 --- a/resources/views/Shop/Articles/partials/addBasket.blade.php +++ b/resources/views/Shop/Articles/partials/addBasket.blade.php @@ -12,14 +12,14 @@ ])
-
+
@include('components.form.inputs.number', [ 'name' => 'quantity', 'id_name' => $model . '-quantity', 'value' => 1, ])
-
+
{{ $data[0]['prices'][0]['price_taxed'] }} diff --git a/resources/views/Shop/auth/register.blade.php b/resources/views/Shop/auth/register.blade.php index d6101652..4979ccf2 100644 --- a/resources/views/Shop/auth/register.blade.php +++ b/resources/views/Shop/auth/register.blade.php @@ -1,29 +1,91 @@ -@extends('boilerplate::auth.layout', ['title' => __('boilerplate::auth.register.title'), 'bodyClass' => 'hold-transition login-page']) +@extends('Shop.layout.layout', [ + 'title' => __('home.title'), + 'bodyClass' => 'hold-transition login-page' +]) @section('content') - @component('boilerplate::auth.loginbox') - - {!! Form::open(['route' => 'Shop.register.post', 'method' => 'post', 'autocomplete'=> 'off']) !!} -
- {{ Form::text('first_name', old('first_name'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.first_name'), 'required', 'autofocus']) }} - {!! $errors->first('first_name','

:message

') !!} -
-
- {{ Form::text('last_name', old('last_name'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.last_name'), 'required']) }} - {!! $errors->first('last_name','

:message

') !!} -
-
- {{ Form::email('email', old('email'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.email'), 'required']) }} - {!! $errors->first('email','

:message

') !!} -
-
- {{ Form::password('password', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password'), 'required']) }} - {!! $errors->first('password','

:message

') !!} -
-
- {{ Form::password('password_confirmation', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password_confirm'), 'required']) }} - {!! $errors->first('password_confirmation','

:message

') !!} -
+ {!! Form::open(['route' => 'Shop.register.post', 'method' => 'post', 'autocomplete'=> 'off']) !!} +
+
+ @component('components.card', ['title' => 'Créez votre compte', 'class' => 'mt-3 mb-3']) +
+
+
+ {{ Form::text('first_name', old('first_name'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.first_name'), 'required', 'autofocus']) }} + {!! $errors->first('first_name','

:message

') !!} +
+
+
+
+ {{ Form::text('last_name', old('last_name'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.last_name'), 'required']) }} + {!! $errors->first('last_name','

:message

') !!} +
+
+
+
+
+
+ {{ Form::email('email', old('email'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.email'), 'required']) }} + {!! $errors->first('email','

:message

') !!} +
+
+
+
+ {{ Form::text('phone', old('phone'), ['class' => 'form-control', 'placeholder' => __('phone'), 'required']) }} + {!! $errors->first('phone','

:message

') !!} +
+
+
+ +
+
+
+ {{ Form::text('address', old('address'), ['class' => 'form-control', 'placeholder' => __('Adresse'), 'required']) }} + {!! $errors->first('address','

:message

') !!} +
+
+
+ +
+
+
+ {{ Form::text('address2', old('address2'), ['class' => 'form-control', 'placeholder' => __('Complément d\'adresse'), 'required']) }} + {!! $errors->first('address2','

:message

') !!} +
+
+
+ +
+
+
+ {{ Form::text('zipcode', old('zipcode'), ['class' => 'form-control', 'placeholder' => __('zipcode'), 'required']) }} + {!! $errors->first('zipcode','

:message

') !!} +
+
+
+
+ {{ Form::text('city', old('city'), ['class' => 'form-control', 'placeholder' => __('city'), 'required']) }} + {!! $errors->first('city','

:message

') !!} +
+
+
+ +
+
+
+ {{ Form::password('password', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password'), 'required']) }} + {!! $errors->first('password','

:message

') !!} +
+
+
+
+ {{ Form::password('password_confirmation', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password_confirm'), 'required']) }} + {!! $errors->first('password_confirmation','

:message

') !!} +
+
+
+ @endcomponent +
- {!! Form::close() !!} - @endcomponent + +
+
+ {!! Form::close() !!} @endsection diff --git a/resources/views/Shop/layout/partials/header-profile.blade.php b/resources/views/Shop/layout/partials/header-profile.blade.php index a97e2487..401f719c 100644 --- a/resources/views/Shop/layout/partials/header-profile.blade.php +++ b/resources/views/Shop/layout/partials/header-profile.blade.php @@ -2,11 +2,13 @@