From a1fd36aa6fdc70ad10456e50b98d96b2e2d10a54 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 6 Aug 2022 00:22:22 +1000 Subject: [PATCH] Update supplier details to use form helpers, and added in api settings --- app/Http/Controllers/SupplierController.php | 8 +- app/Http/Requests/SupplierAddEdit.php | 2 + composer.lock | 22 +-- config/services.php | 6 + .../adminlte/supplier/details.blade.php | 1 - .../backend/adminlte/supplier/home.blade.php | 38 ++-- .../adminlte/supplier/widget/detail.blade.php | 179 +++++++++--------- 7 files changed, 128 insertions(+), 128 deletions(-) diff --git a/app/Http/Controllers/SupplierController.php b/app/Http/Controllers/SupplierController.php index 57ff68d..469cb18 100644 --- a/app/Http/Controllers/SupplierController.php +++ b/app/Http/Controllers/SupplierController.php @@ -19,7 +19,7 @@ class SupplierController extends Controller { $this->middleware(['auth','wholesaler']); - foreach ($request->except(['_token','supplier_details','submit']) as $key => $item) + foreach ($request->except(['_token','supplier_details','api_key','api_secret','submit']) as $key => $item) $o->{$key} = $item; $o->active = (bool)$request->active; @@ -37,10 +37,14 @@ class SupplierController extends Controller foreach ($request->get('supplier_details',[]) as $key => $item) $oo->{$key} = $item; + $oo->connections = $oo->connections->merge([ + 'api_key'=>$request->get('api_key'), + 'api_secret'=>$request->get('api_secret'), + ])->filter(); $o->detail()->save($oo); return redirect()->back() - ->with('success','Supplier saved'); + ->with('success','Supplier Saved'); } /** diff --git a/app/Http/Requests/SupplierAddEdit.php b/app/Http/Requests/SupplierAddEdit.php index c1d5897..0b11e1f 100644 --- a/app/Http/Requests/SupplierAddEdit.php +++ b/app/Http/Requests/SupplierAddEdit.php @@ -39,6 +39,8 @@ class SupplierAddEdit extends FormRequest 'supplier_details.accounts' => 'nullable|email', 'supplier_details.support' => 'nullable|email', 'supplier_details.payments' => 'nullable|string|min:3', + 'api_key' => 'nullable|string|min:3', + 'api_secret' => 'nullable|string|min:3', ]; } } \ No newline at end of file diff --git a/composer.lock b/composer.lock index bf09081..ca01267 100644 --- a/composer.lock +++ b/composer.lock @@ -3377,11 +3377,11 @@ }, { "name": "leenooks/laravel", - "version": "9.2.4", + "version": "9.2.5", "source": { "type": "git", "url": "https://dev.leenooks.net/leenooks/laravel", - "reference": "61f38aefe78b4d8af630aee8c50271e50084d63c" + "reference": "d494400e7eae16626016c6165acf89c18333ff1b" }, "require": { "creativeorange/gravatar": "^1.0", @@ -3420,7 +3420,7 @@ "laravel", "leenooks" ], - "time": "2022-08-03T06:32:38+00:00" + "time": "2022-08-05T14:19:20+00:00" }, { "name": "leenooks/laravel-theme", @@ -5596,16 +5596,16 @@ }, { "name": "stella-maris/clock", - "version": "0.1.4", + "version": "0.1.5", "source": { "type": "git", - "url": "https://gitlab.com/stella-maris/clock.git", - "reference": "8a0a967896df4c63417385dc69328a0aec84d9cf" + "url": "git@gitlab.com:stella-maris/clock.git", + "reference": "447879c53ca0b2a762cdbfba5e76ccf4deca9158" }, "dist": { "type": "zip", - "url": "https://gitlab.com/api/v4/projects/stella-maris%2Fclock/repository/archive.zip?sha=8a0a967896df4c63417385dc69328a0aec84d9cf", - "reference": "8a0a967896df4c63417385dc69328a0aec84d9cf", + "url": "https://gitlab.com/api/v4/projects/stella-maris%2Fclock/repository/archive.zip?sha=447879c53ca0b2a762cdbfba5e76ccf4deca9158", + "reference": "447879c53ca0b2a762cdbfba5e76ccf4deca9158", "shasum": "" }, "require": { @@ -5635,11 +5635,7 @@ "point in time", "psr20" ], - "support": { - "issues": "https://gitlab.com/stella-maris/clock/-/issues", - "source": "https://gitlab.com/stella-maris/clock/-/tree/0.1.4" - }, - "time": "2022-04-17T14:12:26+00:00" + "time": "2022-08-05T07:21:25+00:00" }, { "name": "symfony/console", diff --git a/config/services.php b/config/services.php index 08e9214..960491d 100644 --- a/config/services.php +++ b/config/services.php @@ -42,4 +42,10 @@ return [ 'client_secret' => env('AUTH_GOOGLE_SECRET'), 'redirect' => '/auth/google/callback', ], + + 'supplier' => [ + 'crazydomain' => [ + 'api'=> \Dreamscape\API::class, + ] + ], ]; diff --git a/resources/views/theme/backend/adminlte/supplier/details.blade.php b/resources/views/theme/backend/adminlte/supplier/details.blade.php index bf5c00d..c2aeeca 100644 --- a/resources/views/theme/backend/adminlte/supplier/details.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/details.blade.php @@ -11,7 +11,6 @@ {{ $o->name ?: 'New Supplier' }} @endsection @section('contentheader_description') - @include('adminlte::widget.status') @endsection @section('main-content') diff --git a/resources/views/theme/backend/adminlte/supplier/home.blade.php b/resources/views/theme/backend/adminlte/supplier/home.blade.php index 2735738..633c181 100644 --- a/resources/views/theme/backend/adminlte/supplier/home.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/home.blade.php @@ -26,29 +26,17 @@ @csrf
-
-
- - - - @error('name') - {{ $message }} - @else - Supplier Name is required. - @enderror - - Suppliers Name -
+
+ @include('adminlte::widget.form_select',[ + 'label'=>'Supplier', + 'icon'=>'fas fa-handshake', + 'id'=>'supplier_id', + 'old'=>'supplier_id', + 'name'=>'supplier_id', + 'groupby'=>'active', + 'options'=>\App\Models\Supplier::orderBy('active','DESC')->orderBy('name')->get()->transform(function($item) { return ['id'=>$item->id,'value'=>$item->name,'active'=>$item->active]; }), + 'value'=>'', + ])
@@ -64,10 +52,10 @@ -@endsection \ No newline at end of file +@append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/supplier/widget/detail.blade.php b/resources/views/theme/backend/adminlte/supplier/widget/detail.blade.php index b41bf2c..35b0343 100644 --- a/resources/views/theme/backend/adminlte/supplier/widget/detail.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/widget/detail.blade.php @@ -1,11 +1,8 @@
-

Supplier Details

+

Supplier Details @include('adminlte::widget.success_button')


- @if(session()->has('success')) - {{ session()->get('success') }} - @endif
@csrf @@ -13,39 +10,35 @@
- -
-
- - - - @error('name') - {{ $message }} - @else - Supplier Name required. - @enderror - -
-
- -
-
+
+
active) ? 'checked' : '' }}>
+ + +
+ @include('adminlte::widget.form_text',[ + 'label'=>'Supplier Name', + 'id'=>'name', + 'old'=>'name', + 'name'=>'name', + 'value'=>$o->name ?? '', + ]) +
-
+
- - + + @error('address1') {{ $message }} @@ -60,49 +53,37 @@
-
- - - - @error('city') - {{ $message }} - @else - City is required. - @enderror - -
+ @include('adminlte::widget.form_text',[ + 'label'=>'City', + 'id'=>'city', + 'old'=>'city', + 'name'=>'city', + 'value'=>$o->city ?? '', + ])
-
-
- - - - @error('state') - {{ $message }} - @else - State is required. - @enderror - -
+
+ @include('adminlte::widget.form_text',[ + 'label'=>'State', + 'id'=>'state', + 'old'=>'state', + 'name'=>'state', + 'value'=>$o->state ?? '', + ])
-
-
- - - - @error('postcode') - {{ $message }} - @else - Postcode is required. - @enderror - -
+
+ @include('adminlte::widget.form_text',[ + 'label'=>'Post Code', + 'id'=>'postcode', + 'old'=>'postcode', + 'name'=>'postcode', + 'value'=>$o->postcode ?? '', + ])
@@ -111,47 +92,72 @@
-
- - - - @error('supplier_details.accounts') - {{ $message }} - @enderror - -
+ @include('adminlte::widget.form_text',[ + 'label'=>'Accounts Email', + 'id'=>'supplier_details.accounts', + 'old'=>'supplier_details.accounts', + 'name'=>'supplier_details[accounts]', + 'value'=>($o->detail ? $o->detail->accounts : ''), + ])
-
- - - - @error('supplier_details.support') - {{ $message }} - @enderror - -
+ @include('adminlte::widget.form_text',[ + 'label'=>'Support Email', + 'id'=>'supplier_details.support', + 'old'=>'supplier_details.support', + 'name'=>'supplier_details[support]', + 'value'=>($o->detail ? $o->detail->support : ''), + ])
-
- - - - @error('supplier_details.payments') - {{ $message }} - @enderror - -
+ @include('adminlte::widget.form_text',[ + 'label'=>'Payment Details', + 'id'=>'supplier_details.payments', + 'old'=>'supplier_details.payments', + 'name'=>'supplier_details[payments]', + 'value'=>($o->detail ? $o->detail->support : ''), + ])
+ + @if($x=config('services.supplier.'.$o->name.'.api')) +
+

{{ $x }}

+ +
+ +
+ @include('adminlte::widget.form_text',[ + 'label'=>'API Key', + 'id'=>'api_key', + 'old'=>'api_key', + 'name'=>'api_key', + 'value'=>($o->detail ? Arr::get($o->detail->connections,'api_key') : ''), + ]) +
+
+ +
+ +
+ @include('adminlte::widget.form_text',[ + 'label'=>'API Secret', + 'id'=>'api_secret', + 'old'=>'api_secret', + 'name'=>'api_secret', + 'value'=>($o->detail ? Arr::get($o->detail->connections,'api_secret') : ''), + ]) +
+
+ @endif
@@ -161,7 +167,6 @@
- Notes. @error('supplier_details.notes') {{ $message }}