Update supplier details to use form helpers, and added in api settings
This commit is contained in:
parent
ae3f97d890
commit
a1fd36aa6f
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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',
|
||||
];
|
||||
}
|
||||
}
|
22
composer.lock
generated
22
composer.lock
generated
@ -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",
|
||||
|
@ -42,4 +42,10 @@ return [
|
||||
'client_secret' => env('AUTH_GOOGLE_SECRET'),
|
||||
'redirect' => '/auth/google/callback',
|
||||
],
|
||||
|
||||
'supplier' => [
|
||||
'crazydomain' => [
|
||||
'api'=> \Dreamscape\API::class,
|
||||
]
|
||||
],
|
||||
];
|
||||
|
@ -11,7 +11,6 @@
|
||||
{{ $o->name ?: 'New Supplier' }}
|
||||
@endsection
|
||||
@section('contentheader_description')
|
||||
@include('adminlte::widget.status')
|
||||
@endsection
|
||||
|
||||
@section('main-content')
|
||||
|
@ -26,29 +26,17 @@
|
||||
@csrf
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group has-validation">
|
||||
<label for="name">Supplier Name</label>
|
||||
<select class="form-control form-control-border" id="name" name="supplier_id">
|
||||
<option value=""></option>
|
||||
<option value="">Add New</option>
|
||||
@foreach(\App\Models\Supplier::orderBy('active','DESC')->orderBy('name')->get()->groupBy('active') as $o)
|
||||
<optgroup label="{{ $o->first()->active ? 'Active' : 'Not Active' }}">
|
||||
@foreach($o as $oo)
|
||||
<option value="{{ $oo->id }}">{{ $oo->name }}</option>
|
||||
@endforeach
|
||||
</optgroup>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('name')
|
||||
{{ $message }}
|
||||
@else
|
||||
Supplier Name is required.
|
||||
@enderror
|
||||
</span>
|
||||
<span class="input-helper">Suppliers Name</span>
|
||||
</div>
|
||||
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
|
||||
@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'=>'',
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -64,10 +52,10 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#name').select2()
|
||||
$('#supplier_id')
|
||||
.on('change',function(item) {
|
||||
window.location.href = '{{ url('a/supplier/details') }}'+(item.target.value ? '/'+item.target.value : '');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@append
|
@ -1,11 +1,8 @@
|
||||
<!-- $o = Supplier::class -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h3>Supplier Details</h3>
|
||||
<h3>Supplier Details @include('adminlte::widget.success_button')</h3>
|
||||
<hr>
|
||||
@if(session()->has('success'))
|
||||
<span class="ml-3 pt-0 pb-0 pr-1 pl-1 btn btn-outline-success"><small>{{ session()->get('success') }}</small></span>
|
||||
@endif
|
||||
|
||||
<form class="g-0 needs-validation" method="POST" enctype="multipart/form-data" role="form">
|
||||
@csrf
|
||||
@ -13,39 +10,35 @@
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="row">
|
||||
<!-- Supplier Name -->
|
||||
<div class="col-9">
|
||||
<div class="form-group has-validation">
|
||||
<label for="name">Supplier Name</label>
|
||||
<input type="text" class="form-control form-control-border @error('name') is-invalid @enderror" id="name" name="name" placeholder="Supplier Name" value="{{ old('name',$o->name) }}" required>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('name')
|
||||
{{ $message }}
|
||||
@else
|
||||
Supplier Name required.
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Supplier Active -->
|
||||
<div class="col-3">
|
||||
<div class="form-group">
|
||||
<div class="col-12 col-sm-3">
|
||||
<div class="form-group left">
|
||||
<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
|
||||
<input type="checkbox" class="custom-control-input" id="active" name="active" {{ old('active',$o->active) ? 'checked' : '' }}>
|
||||
<label class="custom-control-label" for="active">Active</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Supplier Name -->
|
||||
<div class="col-12 col-sm-9">
|
||||
@include('adminlte::widget.form_text',[
|
||||
'label'=>'Supplier Name',
|
||||
'id'=>'name',
|
||||
'old'=>'name',
|
||||
'name'=>'name',
|
||||
'value'=>$o->name ?? '',
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- Address Lines -->
|
||||
<div class="col-12">
|
||||
<div class="form-group has-validation">
|
||||
<div class="form-group">
|
||||
<label for="address1">Address Lines</label>
|
||||
<input type="text" class="form-control form-control-border @error('address1') is-invalid @enderror" id="address1" name="address1" placeholder="Address1" value="{{ old('address1',$o->address1) }}" required>
|
||||
<input type="text" class="form-control form-control-border" id="address2" name="address2" placeholder="Address2" value="{{ old('address2',$o->address2) }}">
|
||||
<input type="text" style="border-bottom-left-radius:0;border-bottom-right-radius:0;" class="form-control @error('address1') is-invalid @enderror" id="address1" name="address1" value="{{ old('address1',$o->address1) }}">
|
||||
<input type="text" style="border-top-left-radius:0;border-top-right-radius:0;" class="form-control" id="address2" name="address2" value="{{ old('address2',$o->address2) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('address1')
|
||||
{{ $message }}
|
||||
@ -60,49 +53,37 @@
|
||||
<div class="row">
|
||||
<!-- City -->
|
||||
<div class="col-12">
|
||||
<div class="form-group has-validation">
|
||||
<label for="city">City</label>
|
||||
<input type="text" class="form-control form-control-border @error('city') is-invalid @enderror" id="city" name="city" placeholder="City" value="{{ old('city',$o->city) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('city')
|
||||
{{ $message }}
|
||||
@else
|
||||
City is required.
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
@include('adminlte::widget.form_text',[
|
||||
'label'=>'City',
|
||||
'id'=>'city',
|
||||
'old'=>'city',
|
||||
'name'=>'city',
|
||||
'value'=>$o->city ?? '',
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- State -->
|
||||
<div class="col-9">
|
||||
<div class="form-group has-validation">
|
||||
<label for="state">State</label>
|
||||
<input type="text" class="form-control form-control-border @error('state') is-invalid @enderror" id="state" name="state" placeholder="State" value="{{ old('state',$o->state) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('state')
|
||||
{{ $message }}
|
||||
@else
|
||||
State is required.
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-12 col-sm-9">
|
||||
@include('adminlte::widget.form_text',[
|
||||
'label'=>'State',
|
||||
'id'=>'state',
|
||||
'old'=>'state',
|
||||
'name'=>'state',
|
||||
'value'=>$o->state ?? '',
|
||||
])
|
||||
</div>
|
||||
|
||||
<!-- Postal Code -->
|
||||
<div class="col-3">
|
||||
<div class="form-group has-validation">
|
||||
<label for="postcode">Postal Code</label>
|
||||
<input type="text" class="form-control form-control-border @error('postcode') is-invalid @enderror" id="postcode" name="postcode" placeholder="Postal Code" value="{{ old('postcode',$o->postcode) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('postcode')
|
||||
{{ $message }}
|
||||
@else
|
||||
Postcode is required.
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-12 col-sm-3">
|
||||
@include('adminlte::widget.form_text',[
|
||||
'label'=>'Post Code',
|
||||
'id'=>'postcode',
|
||||
'old'=>'postcode',
|
||||
'name'=>'postcode',
|
||||
'value'=>$o->postcode ?? '',
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -111,47 +92,72 @@
|
||||
<div class="row">
|
||||
<!-- Accounts Email -->
|
||||
<div class="col-12">
|
||||
<div class="form-group has-validation">
|
||||
<label for="accounts">Accounts Email</label>
|
||||
<input type="text" class="form-control form-control-border @error('supplier_details.accounts') is-invalid @enderror" id="accounts" name="supplier_details[accounts]" placeholder="Accounts Email" value="{{ old('supplier_details.accounts',($o->detail ? $o->detail->accounts : '')) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('supplier_details.accounts')
|
||||
{{ $message }}
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
@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 : ''),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- Support Email -->
|
||||
<div class="col-12">
|
||||
<div class="form-group has-validation">
|
||||
<label for="support">Support Email</label>
|
||||
<input type="text" class="form-control form-control-border @error('supplier_details.support') is-invalid @enderror" id="support" name="supplier_details[support]" placeholder="Support Email" value="{{ old('supplier_details.support',($o->detail ? $o->detail->support : '')) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('supplier_details.support')
|
||||
{{ $message }}
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
@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 : ''),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- Payment Details -->
|
||||
<div class="col-12">
|
||||
<div class="form-group has-validation">
|
||||
<label for="payments">Payment Details</label>
|
||||
<input type="text" class="form-control form-control-border @error('supplier_details.payments') is-invalid @enderror" id="payments" name="supplier_details[payments]" placeholder="Payment Details" value="{{ old('supplier_details.payments',($o->detail ? $o->detail->payments : '')) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('supplier_details.payments')
|
||||
{{ $message }}
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
@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 : ''),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if($x=config('services.supplier.'.$o->name.'.api'))
|
||||
<hr>
|
||||
<p class="h6"><i class="fa-fw fas fa-sitemap"></i> <strong>{{ $x }}</strong></p>
|
||||
|
||||
<div class="row">
|
||||
<!-- API Details -->
|
||||
<div class="col-12">
|
||||
@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') : ''),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- API Details -->
|
||||
<div class="col-12">
|
||||
@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') : ''),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -161,7 +167,6 @@
|
||||
<div class="form-group has-validation">
|
||||
<label for="notes">Notes</label>
|
||||
<textarea class="form-control @error('supplier_details.notes') is-invalid @enderror" id="notes" name="supplier_details[notes]" placeholder="Notes...">{{ old('supplier_details.notes',($o->detail ? $o->detail->notes : '')) }}</textarea>
|
||||
<span class="input-helper">Notes.</span>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('supplier_details.notes')
|
||||
{{ $message }}
|
||||
|
Loading…
Reference in New Issue
Block a user