From 222724270436faa51d3105cdd899c71b4ed15fc1 Mon Sep 17 00:00:00 2001 From: ludo Date: Mon, 11 Mar 2024 18:38:23 +0100 Subject: [PATCH] fix route --- Gruntfile.js | 24 -- .../Admin/Shop/CustomerAddressController.php | 6 +- .../Shop/Auth/RegisterController.php | 2 +- app/Http/Controllers/Shop/Controller.php | 4 - app/Http/Controllers/Shop/OrderController.php | 3 + build/js/include/form/validator.js | 2 +- .../Shop/CustomerAddresses/create.blade.php | 16 +- .../Shop/CustomerAddresses/form.blade.php | 244 +++++++++--------- resources/views/components/address.blade.php | 172 ++++++------ 9 files changed, 232 insertions(+), 241 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index a06409c4..25dffb8a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -41,40 +41,21 @@ var jsAdminLTE = [ ] var jsCoreInclude = [ - // 'build/js/include/core/appender.js', - // 'build/js/include/core/cache.js', - // 'build/js/include/core/handlebars.js', - // 'build/js/include/core/lang.js', 'build/js/include/core/objectLength.js', - // 'build/js/include/core/session.js', 'build/js/include/core/url.js', 'build/js/include/core/user.js', - // 'build/js/include/form/check_fields.js', - // 'build/js/include/form/checkbox.js', - // 'build/js/include/form/datetime.js', - // 'build/js/include/form/multi-select.js', 'build/js/include/form/radio.js', - // 'build/js/include/form/select.js', 'build/js/include/form/upload.js', 'build/js/include/form/validator.js', 'build/js/include/layout/animate.js', - // 'build/js/include/layout/message.js', - // 'build/js/include/layout/modal.js', 'build/js/include/layout/scroll.js', 'build/js/include/layout/tooltip.js', - // 'build/js/include/datatable.js', - // 'build/js/include/file.js', - // 'build/js/include/uploader.js', ] var jsBundle = [ 'node_modules/jquery-ui-sortable/jquery-ui.min.js', 'node_modules/jquery-serializejson/jquery.serializejson.min.js', - // 'node_modules/moment/min/moment.min.js', 'node_modules/jquery-placeholder/jquery.placeholder.js', - // 'node_modules/daterangepicker/daterangepicker.js', - // 'node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js', - // 'node_modules/bootstrap4-toggle/js/bootstrap4-toggle.min.js', 'node_modules/@claviska/jquery-minicolors/jquery.minicolors.js', 'node_modules/bootstrap-validate/dist/bootstrap-validate.js', 'node_modules/bootstrap-validator/dist/validator.min.js', @@ -87,15 +68,11 @@ var jsBundle = [ 'node_modules/jquery.quicksearch/dist/jquery.quicksearch.min.js', 'node_modules/jquery.nicescroll/dist/jquery.nicescroll.js', 'node_modules/jquery-slimscroll/jquery.slimscroll.min.js', - // 'node_modules/superclick/dist/js/superclick.min.js', - // 'node_modules/dropzone/dist/min/dropzone.min.js', 'node_modules/handlebars/dist/handlebars.min.js', 'node_modules/swag/lib/swag.min.js', 'node_modules/multiselect/js/jquery.multi-select.js', 'node_modules/screenfull/dist/screenfull.js', 'node_modules/underscore/underscore-min.js', - // 'Admin/js/themes/admin/layout.js', -// 'node_modules/wew.js/dist/wew.min.js' ] var jsMain = [ @@ -136,7 +113,6 @@ var cssMain = [ ] var jsDataTables = [ - // 'build/Suite/js/datatables.js', 'node_modules/jszip/dist/jszip.min.js', 'node_modules/pdfmake/build/pdfmake.min.js', 'node_modules/pdfmake/build/vfs_fonts.js', diff --git a/app/Http/Controllers/Admin/Shop/CustomerAddressController.php b/app/Http/Controllers/Admin/Shop/CustomerAddressController.php index 96c92dc8..80741772 100644 --- a/app/Http/Controllers/Admin/Shop/CustomerAddressController.php +++ b/app/Http/Controllers/Admin/Shop/CustomerAddressController.php @@ -15,7 +15,11 @@ class CustomerAddressController extends Controller public function create() { - return view('Admin.Shop.CustomerAddresses.create'); + $data = [ + 'with_country' => false, + ]; + + return view('Admin.Shop.CustomerAddresses.create', $data); } public function store(Request $request) diff --git a/app/Http/Controllers/Shop/Auth/RegisterController.php b/app/Http/Controllers/Shop/Auth/RegisterController.php index 15839173..5c6416b7 100644 --- a/app/Http/Controllers/Shop/Auth/RegisterController.php +++ b/app/Http/Controllers/Shop/Auth/RegisterController.php @@ -45,7 +45,7 @@ class RegisterController extends Controller return $request->wantsJson() ? new JsonResponse([], 201) - : redirect('home'); + : redirect()->route('home'); } public function emailVerify() diff --git a/app/Http/Controllers/Shop/Controller.php b/app/Http/Controllers/Shop/Controller.php index 32073d6a..d31997ee 100644 --- a/app/Http/Controllers/Shop/Controller.php +++ b/app/Http/Controllers/Shop/Controller.php @@ -6,8 +6,4 @@ use App\Http\Controllers\Controller as ParentController; class Controller extends ParentController { - public function __construct() - { - $this->middleware('auth.check'); - } } diff --git a/app/Http/Controllers/Shop/OrderController.php b/app/Http/Controllers/Shop/OrderController.php index 8334ad03..eec82c06 100644 --- a/app/Http/Controllers/Shop/OrderController.php +++ b/app/Http/Controllers/Shop/OrderController.php @@ -18,6 +18,9 @@ class OrderController extends Controller { public function index(CustomerOrdersDataTable $dataTable) { + if (Customers::isNotConnected()) { + abort(403); + } return $dataTable->render('Shop.Orders.partials.list'); } diff --git a/build/js/include/form/validator.js b/build/js/include/form/validator.js index bd7c154a..04f29d93 100644 --- a/build/js/include/form/validator.js +++ b/build/js/include/form/validator.js @@ -1,6 +1,6 @@ function initValidator() { $( document ).ready(function() { - // console.log('initValidator'); + console.log('initValidator'); // $(window).on('load', function() { // window.addEventListener('load', function() { diff --git a/resources/views/Admin/Shop/CustomerAddresses/create.blade.php b/resources/views/Admin/Shop/CustomerAddresses/create.blade.php index 53c18680..30138636 100644 --- a/resources/views/Admin/Shop/CustomerAddresses/create.blade.php +++ b/resources/views/Admin/Shop/CustomerAddresses/create.blade.php @@ -1,11 +1,15 @@ @extends('layout.index', [ - 'title' => __('shop.customers.title'), - 'subtitle' => __('shop.customers.add'), - 'breadcrumb' => [__('shop.customers.title')] + 'title' => __('shop.customer_addresses.title'), + 'subtitle' => __('shop.customer_addresses.add'), + 'breadcrumb' => [__('shop.customers.title')], ]) @section('content') - {{ Form::open(['route' => 'Admin.Shop.Customers.store', 'id' => 'customer-form', 'autocomplete' => 'off']) }} - @include('Admin.Shop.Customers.form') - + {{ Form::open([ + 'route' => 'Admin.Shop.CustomerAddresses.store', + 'id' => 'customer_address-form', + 'autocomplete' => 'off', + ]) }} + @include('components.address') + @endsection diff --git a/resources/views/Admin/Shop/CustomerAddresses/form.blade.php b/resources/views/Admin/Shop/CustomerAddresses/form.blade.php index 8b9a0eb9..d8f27319 100644 --- a/resources/views/Admin/Shop/CustomerAddresses/form.blade.php +++ b/resources/views/Admin/Shop/CustomerAddresses/form.blade.php @@ -1,123 +1,123 @@
-
-
-
- {{ Form::label('first_name', 'Prénom') }} - @include('components.form.input', [ - 'name' => 'first_name', - 'value' => $customer['first_name'] ?? null, - 'required' => true, - ]) -
-
- {{ Form::label('last_name', 'Nom') }} - @include('components.form.input', [ - 'name' => 'last_name', - 'value' => $customer['last_name'] ?? null, - 'required' => true, - ]) -
-
-
-
- {{ Form::label('company', 'Société') }} - @include('components.form.input', [ - 'name' => 'company', - 'value' => $customer['company'] ?? null, - ]) -
-
-
-
- {{ Form::label('tva', 'TVA') }} - @include('components.form.input', [ - 'name' => 'tva', - 'value' => $customer['tva'] ?? null, - ]) -
-
-
-
- {{ Form::label('email', 'Email') }} - @include('components.form.input', [ - 'name' => 'email', - 'value' => $customer['email'] ?? null, - 'required' => true, - ]) -
-
- {{ Form::label('phone', 'Téléphone') }} - @include('components.form.input', [ - 'name' => 'phone', - 'value' => $customer['phone'] ?? null, - ]) -
-
+
+
+
+ {{ Form::label('first_name', 'Prénom') }} + @include('components.form.input', [ + 'name' => 'first_name', + 'value' => $customer['first_name'] ?? null, + 'required' => true, + ]) +
+
+ {{ Form::label('last_name', 'Nom') }} + @include('components.form.input', [ + 'name' => 'last_name', + 'value' => $customer['last_name'] ?? null, + 'required' => true, + ]) +
+
+
+
+ {{ Form::label('company', 'Société') }} + @include('components.form.input', [ + 'name' => 'company', + 'value' => $customer['company'] ?? null, + ]) +
+
+
+
+ {{ Form::label('tva', 'TVA') }} + @include('components.form.input', [ + 'name' => 'tva', + 'value' => $customer['tva'] ?? null, + ]) +
+
+
+
+ {{ Form::label('email', 'Email') }} + @include('components.form.input', [ + 'name' => 'email', + 'value' => $customer['email'] ?? null, + 'required' => true, + ]) +
+
+ {{ Form::label('phone', 'Téléphone') }} + @include('components.form.input', [ + 'name' => 'phone', + 'value' => $customer['phone'] ?? null, + ]) +
+
-
-
- {{ Form::label('address', 'Adresse') }} - @include('components.form.input', [ - 'name' => 'address', - 'value' => $customer['address'] ?? null, - 'required' => true, - ]) -
-
+
+
+ {{ Form::label('address', 'Adresse') }} + @include('components.form.input', [ + 'name' => 'address', + 'value' => $customer['address'] ?? null, + 'required' => true, + ]) +
+
-
-
- {{ Form::label('address2', 'Adresse complémentaire') }} - @include('components.form.input', [ - 'name' => 'address2', - 'value' => $customer['address2'] ?? null, - ]) -
-
+
+
+ {{ Form::label('address2', 'Adresse complémentaire') }} + @include('components.form.input', [ + 'name' => 'address2', + 'value' => $customer['address2'] ?? null, + ]) +
+
-
-
- {{ Form::label('zipcode', 'Code postal') }} - @include('components.form.input', [ - 'name' => 'zipcode', - 'value' => $customer['zipcode'] ?? null, - 'required' => true, - ]) -
-
- {{ Form::label('city', 'Ville') }} - @include('components.form.input', [ - 'name' => 'city', - 'value' => $customer['city'] ?? null, - 'required' => true, - ]) -
-
+
+
+ {{ Form::label('zipcode', 'Code postal') }} + @include('components.form.input', [ + 'name' => 'zipcode', + 'value' => $customer['zipcode'] ?? null, + 'required' => true, + ]) +
+
+ {{ Form::label('city', 'Ville') }} + @include('components.form.input', [ + 'name' => 'city', + 'value' => $customer['city'] ?? null, + 'required' => true, + ]) +
+
-
-
- {{ Form::label('sale_delivery_id', __('shop.deliveries.name')) }} - @include('components.form.select', [ - 'name' => 'deliveries[]', - 'list' => $deliveries ?? [], - 'values' => $customer['deliveries'] ?? null, - 'with_empty' => '', - 'class' => 'select2', - 'multiple' => true, - ]) -
-
-
-
- @if ($customer['addresses']) - @include('components.address', [ - 'with_country' => false, - 'prefix' => 'addresses[0]', - 'with_tab' => true, - 'item' => $customer['addresses'][0], - ]) - @endif -
+
+
+ {{ Form::label('sale_delivery_id', __('shop.deliveries.name')) }} + @include('components.form.select', [ + 'name' => 'deliveries[]', + 'list' => $deliveries ?? [], + 'values' => $customer['deliveries'] ?? null, + 'with_empty' => '', + 'class' => 'select2', + 'multiple' => true, + ]) +
+
+
+
+ @if ($customer['addresses']) + @include('components.address', [ + 'with_country' => false, + 'prefix' => 'addresses[0]', + 'with_tab' => true, + 'item' => $customer['addresses'][0], + ]) + @endif +
@include('components.save') @@ -126,10 +126,10 @@ @include('load.form.select2') @push('js') - -@endpush \ No newline at end of file + +@endpush diff --git a/resources/views/components/address.blade.php b/resources/views/components/address.blade.php index 8c4f672f..9c5d183b 100644 --- a/resources/views/components/address.blade.php +++ b/resources/views/components/address.blade.php @@ -1,84 +1,92 @@ @if (($mode ?? false) == 'view') -
- @if ($item[($prefix ?? null) . 'address']) - {{ $item[($prefix ?? null) . 'address'] ?? null }}
- @endif - @if ($item[($prefix ?? null) . 'address2']) - {{ $item[($prefix ?? null) . 'address2'] ?? null }} - @endif - @if ($item[($prefix ?? null) . 'zipcode']) - {{ $item[($prefix ?? null) . 'zipcode'] ?? null }} - @endif - @if ($item[($prefix ?? null) . 'city']) - {{ $item[($prefix ?? null) . 'city'] ?? null }} - @endif - @if ($item[($prefix ?? null) . 'state']) - {{ $item[($prefix ?? null) . 'state'] ?? null }} - @endif - @if ($item[($prefix ?? null) . 'country_id']) - {{ $countries[$item[($prefix ?? null) . 'country_id']] ?? null }}
- @endif +
+ @if ($item[($prefix ?? null) . 'address']) + {{ $item[($prefix ?? null) . 'address'] ?? null }}
+ @endif + @if ($item[($prefix ?? null) . 'address2']) + {{ $item[($prefix ?? null) . 'address2'] ?? null }} + @endif + @if ($item[($prefix ?? null) . 'zipcode']) + {{ $item[($prefix ?? null) . 'zipcode'] ?? null }} + @endif + @if ($item[($prefix ?? null) . 'city']) + {{ $item[($prefix ?? null) . 'city'] ?? null }} + @endif + @if ($item[($prefix ?? null) . 'state']) + {{ $item[($prefix ?? null) . 'state'] ?? null }} + @endif + @if ($item[($prefix ?? null) . 'country_id']) + {{ $countries[$item[($prefix ?? null) . 'country_id']] ?? null }}
+ @endif @else - @if ($with_id ?? false) - - @endif -
-
- @include('components.form.input', [ - 'label' => __('street'), - 'name' => ($prefix ?? null) . (($with_tab ?? false) ? '[address]' : 'address'), - 'value' => ($with_tab ?? false) ? $item['address'] ?? null : ($item[($prefix ?? null) . 'address'] ?? null), - 'disabled' => $disabled ?? false - ]) -
-
- @include('components.form.input', [ - 'label' => __('street_complement'), - 'name' => ($prefix ?? null) . (($with_tab ?? false) ? '[address2]' : 'address2'), - 'value' => ($with_tab ?? false) ? $item['address2'] ?? null : ($item[($prefix ?? null) . 'address2'] ?? null), - 'disabled' => $disabled ?? false, - ]) -
-
-
-
- @include('components.form.input', [ - 'label' => __('zipcode'), - 'name' => ($prefix ?? null) . (($with_tab ?? false) ? '[zipcode]' : 'zipcode'), - 'value' => ($with_tab ?? false) ? $item['zipcode'] ?? null : ($item[($prefix ?? null) . 'zipcode'] ?? null), - 'disabled' => $disabled ?? false, - ]) -
-
- @include('components.form.input', [ - 'label' => __('city'), - 'name' => ($prefix ?? null) . (($with_tab ?? false) ? '[city]' : 'city'), - 'value' => ($with_tab ?? false) ? $item['city'] ?? null : ($item[($prefix ?? null) . 'city'] ?? null), - 'disabled' => $disabled ?? false, - ]) -
-
- @if ($with_country ?? true) -
-
- @include('components.form.select', [ - 'label' => __('country'), - 'name' => ($prefix ?? null) . (($with_tab ?? false) ? '[country_id]' : 'country_id'), - 'list' => $countries ?? null, - 'value' => ($with_tab ?? false) ? $item['country_id'] ?? null : ($item[($prefix ?? null) . 'country_id'] ?? null), - 'with_empty' => '', - 'required' => true, - 'disabled' => $disabled ?? false, - ]) -
-
- @include('components.form.input', [ - 'label' => çç('state'), - 'name' => ($prefix ?? null) . (($with_tab ?? false) ? '[state]' : 'state'), - 'value' => ($with_tab ?? false) ? $item['state'] ?? null : ($item[($prefix ?? null) . 'state'] ?? null), - 'disabled' => $disabled ?? false, - ]) -
-
- @endif -@endif \ No newline at end of file + @if ($with_id ?? false) + + @endif +
+
+ @include('components.form.input', [ + 'label' => __('street'), + 'name' => ($prefix ?? null) . ($with_tab ?? false ? '[address]' : 'address'), + 'value' => + $with_tab ?? false ? $item['address'] ?? null : $item[($prefix ?? null) . 'address'] ?? null, + 'disabled' => $disabled ?? false, + ]) +
+
+ @include('components.form.input', [ + 'label' => __('street_complement'), + 'name' => ($prefix ?? null) . ($with_tab ?? false ? '[address2]' : 'address2'), + 'value' => + $with_tab ?? false ? $item['address2'] ?? null : $item[($prefix ?? null) . 'address2'] ?? null, + 'disabled' => $disabled ?? false, + ]) +
+
+
+
+ @include('components.form.input', [ + 'label' => __('zipcode'), + 'name' => ($prefix ?? null) . ($with_tab ?? false ? '[zipcode]' : 'zipcode'), + 'value' => + $with_tab ?? false ? $item['zipcode'] ?? null : $item[($prefix ?? null) . 'zipcode'] ?? null, + 'disabled' => $disabled ?? false, + ]) +
+
+ @include('components.form.input', [ + 'label' => __('city'), + 'name' => ($prefix ?? null) . ($with_tab ?? false ? '[city]' : 'city'), + 'value' => $with_tab ?? false ? $item['city'] ?? null : $item[($prefix ?? null) . 'city'] ?? null, + 'disabled' => $disabled ?? false, + ]) +
+
+ @if ($with_country ?? true) +
+
+ @include('components.form.select', [ + 'label' => __('country'), + 'name' => ($prefix ?? null) . ($with_tab ?? false ? '[country_id]' : 'country_id'), + 'list' => $countries ?? null, + 'value' => + $with_tab ?? false + ? $item['country_id'] ?? null + : $item[($prefix ?? null) . 'country_id'] ?? null, + 'with_empty' => '', + 'required' => true, + 'disabled' => $disabled ?? false, + ]) +
+
+ @include('components.form.input', [ + 'label' => 'state', + 'name' => ($prefix ?? null) . ($with_tab ?? false ? '[state]' : 'state'), + 'value' => + $with_tab ?? false ? $item['state'] ?? null : $item[($prefix ?? null) . 'state'] ?? null, + 'disabled' => $disabled ?? false, + ]) +
+
+ @endif +@endif