[Enhancement #737: Fields added to the customer DataGrid and customer addresses section added at admin end.]
This commit is contained in:
parent
8fe90bc0f6
commit
f8767adc0d
|
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Admin\DataGrids;
|
||||
|
||||
use DB;
|
||||
use Webkul\Ui\DataGrid\DataGrid;
|
||||
use Webkul\Customer\Repositories\CustomerRepository as Customer;
|
||||
|
||||
/**
|
||||
* Address Data Grid class
|
||||
*
|
||||
* @author Vivek Sharma <viveksh047@webkul.com>
|
||||
* @copyright 2019 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class AddressDataGrid extends DataGrid
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $index = 'address_id';
|
||||
|
||||
protected $sortOrder = 'desc'; //asc or desc
|
||||
|
||||
/**
|
||||
* CustomerRepository object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $customer;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Customer\Repositories\CustomerRepository $customer
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
Customer $customer
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->customer = $customer;
|
||||
}
|
||||
|
||||
public function prepareQueryBuilder()
|
||||
{
|
||||
|
||||
$customer = $this->customer->find(request('id'));
|
||||
|
||||
$queryBuilder = DB::table('customer_addresses as ca')
|
||||
->leftJoin('countries', 'ca.country', '=', 'countries.code')
|
||||
->leftJoin('customers as c', 'ca.customer_id', '=', 'c.id')
|
||||
->addSelect('ca.id as address_id', 'ca.address1', 'ca.country', DB::raw('countries.name as country_name'), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address')
|
||||
->where('c.id', $customer->id);
|
||||
|
||||
$queryBuilder = $queryBuilder->leftJoin('country_states', function($qb) {
|
||||
$qb->on('ca.state', 'country_states.code')
|
||||
->on('countries.id', 'country_states.country_id');
|
||||
});
|
||||
|
||||
$queryBuilder
|
||||
->groupBy('ca.id')
|
||||
->addSelect(DB::raw('country_states.default_name as state_name'));
|
||||
|
||||
$this->addFilter('address_id', 'ca.id');
|
||||
$this->addFilter('address1', 'ca.address1');
|
||||
$this->addFilter('city', 'ca.city');
|
||||
$this->addFilter('state_name', DB::raw('country_states.default_name'));
|
||||
$this->addFilter('country_name', DB::raw('countries.name'));
|
||||
$this->addFilter('postcode', 'ca.postcode');
|
||||
$this->addFilter('default_address', 'ca.default_address');
|
||||
|
||||
$this->setQueryBuilder($queryBuilder);
|
||||
}
|
||||
|
||||
public function addColumns()
|
||||
{
|
||||
$this->addColumn([
|
||||
'index' => 'address_id',
|
||||
'label' => trans('admin::app.customers.addresses.address-id'),
|
||||
'type' => 'number',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'address1',
|
||||
'label' => trans('admin::app.customers.addresses.address-1'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'city',
|
||||
'label' => trans('admin::app.customers.addresses.city'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'state_name',
|
||||
'label' => trans('admin::app.customers.addresses.state-name'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'country_name',
|
||||
'label' => trans('admin::app.customers.addresses.country-name'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'postcode',
|
||||
'label' => trans('admin::app.customers.addresses.postcode'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'default_address',
|
||||
'label' => trans('admin::app.customers.addresses.default-address'),
|
||||
'type' => 'boolean',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'closure' => true,
|
||||
'wrapper' => function($row) {
|
||||
if ($row->default_address == 1)
|
||||
return '<span class="badge badge-md badge-success"">' . trans('admin::app.customers.addresses.yes') . '</span>';
|
||||
else
|
||||
return trans('admin::app.customers.addresses.dash');
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
public function prepareActions()
|
||||
{
|
||||
$this->addAction([
|
||||
'type' => 'Edit',
|
||||
'method' => 'GET', //use post only for redirects only
|
||||
'route' => 'admin.customer.addresses.edit',
|
||||
'icon' => 'icon pencil-lg-icon'
|
||||
]);
|
||||
|
||||
$this->addAction([
|
||||
'type' => 'Delete',
|
||||
'method' => 'POST',
|
||||
'route' => 'admin.customer.addresses.delete',
|
||||
'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'address']),
|
||||
'icon' => 'icon trash-icon'
|
||||
]);
|
||||
}
|
||||
|
||||
public function prepareMassActions()
|
||||
{
|
||||
$this->addMassAction([
|
||||
'type' => 'delete',
|
||||
'label' => trans('admin::app.customers.addresses.delete'),
|
||||
'action' => route('admin.customer.addresses.massdelete', request('id')),
|
||||
'method' => 'DELETE'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -23,11 +23,12 @@ class CustomerDataGrid extends DataGrid
|
|||
{
|
||||
$queryBuilder = DB::table('customers')
|
||||
->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id')
|
||||
->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name', 'status')
|
||||
->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name', 'customers.phone', 'customers.gender', 'status')
|
||||
->addSelect(DB::raw('CONCAT(customers.first_name, " ", customers.last_name) as full_name'));
|
||||
|
||||
$this->addFilter('customer_id', 'customers.id');
|
||||
$this->addFilter('full_name', DB::raw('CONCAT(customers.first_name, " ", customers.last_name)'));
|
||||
$this->addFilter('date_of_birth', 'customers.date_of_birth');
|
||||
|
||||
$this->setQueryBuilder($queryBuilder);
|
||||
}
|
||||
|
|
@ -70,6 +71,38 @@ class CustomerDataGrid extends DataGrid
|
|||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'phone',
|
||||
'label' => trans('admin::app.datagrid.phone'),
|
||||
'type' => 'number',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => false,
|
||||
'closure' => true,
|
||||
'wrapper' => function ($row) {
|
||||
if (! $row->phone)
|
||||
return '-';
|
||||
else
|
||||
return $row->phone;
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'gender',
|
||||
'label' => trans('admin::app.datagrid.gender'),
|
||||
'type' => 'string',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'filterable' => false,
|
||||
'closure' => true,
|
||||
'wrapper' => function ($row) {
|
||||
if (! $row->gender)
|
||||
return '-';
|
||||
else
|
||||
return $row->gender;
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'status',
|
||||
'label' => trans('admin::app.datagrid.status'),
|
||||
|
|
@ -77,11 +110,12 @@ class CustomerDataGrid extends DataGrid
|
|||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
'closure' => true,
|
||||
'wrapper' => function ($row) {
|
||||
if ($row->status == 1) {
|
||||
return 'Activated';
|
||||
return '<span class="badge badge-md badge-success">Activated</span>';
|
||||
} else {
|
||||
return 'Blocked';
|
||||
return '<span class="badge badge-md badge-danger">Blocked</span>';
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
|
@ -95,6 +129,13 @@ class CustomerDataGrid extends DataGrid
|
|||
'title' => trans('admin::app.customers.customers.edit-help-title')
|
||||
]);
|
||||
|
||||
$this->addAction([
|
||||
'type' => 'Edit',
|
||||
'method' => 'GET', //use post only for redirects only
|
||||
'route' => 'admin.customer.addresses.index',
|
||||
'icon' => 'icon list-icon'
|
||||
]);
|
||||
|
||||
$this->addAction([
|
||||
'method' => 'POST', // use GET request only for redirect purposes
|
||||
'route' => 'admin.customer.delete',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,189 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Admin\Http\Controllers\Customer;
|
||||
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Customer\Repositories\CustomerRepository as Customer;
|
||||
use Webkul\Customer\Repositories\CustomerAddressRepository as CustomerAddress;
|
||||
|
||||
/**
|
||||
* Customer's Address controller
|
||||
*
|
||||
* @author Vivek Sharma <viveksh047@webkul.com>
|
||||
* @copyright 2019 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class AddressController extends Controller
|
||||
{
|
||||
/**
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* Customer Repository object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $customer;
|
||||
|
||||
/**
|
||||
* CustomerAddress Repository object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $customerAddress;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Customer\Repositories\CustomerAddressRepository $customerAddress
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
Customer $customer,
|
||||
CustomerAddress $customerAddress
|
||||
)
|
||||
{
|
||||
$this->customer = $customer;
|
||||
|
||||
$this->customerAddress = $customerAddress;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to populate the seller order page which will be populated.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
public function index($id)
|
||||
{
|
||||
$customer = $this->customer->find($id);
|
||||
|
||||
return view($this->_config['view'], compact('customer'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create($id)
|
||||
{
|
||||
$customer = $this->customer->find($id);
|
||||
|
||||
return view($this->_config['view'], compact('customer'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
request()->merge(['address1' => implode(PHP_EOL, array_filter(request()->input('address1')))]);
|
||||
|
||||
$data = collect(request()->input())->except('_token')->toArray();
|
||||
|
||||
$this->validate(request(), [
|
||||
'address1' => 'string|required',
|
||||
'country' => 'string|required',
|
||||
'state' => 'string|required',
|
||||
'city' => 'string|required',
|
||||
'postcode' => 'required',
|
||||
'phone' => 'required'
|
||||
]);
|
||||
|
||||
if ( $this->customerAddress->create($data) ) {
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-create'));
|
||||
|
||||
return redirect()->route('admin.customer.addresses.index', ['id' => $data['customer_id']]);
|
||||
} else {
|
||||
session()->flash('success', trans('admin::app.customers.addresses.error-create'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$address = $this->customerAddress->find($id);
|
||||
|
||||
return view($this->_config['view'], compact('address'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit's the premade resource of customer called
|
||||
* Address.
|
||||
*
|
||||
* @return redirect
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
request()->merge(['address1' => implode(PHP_EOL, array_filter(request()->input('address1')))]);
|
||||
|
||||
$this->validate(request(), [
|
||||
'address1' => 'string|required',
|
||||
'country' => 'string|required',
|
||||
'state' => 'string|required',
|
||||
'city' => 'string|required',
|
||||
'postcode' => 'required',
|
||||
'phone' => 'required'
|
||||
]);
|
||||
|
||||
$data = collect(request()->input())->except('_token')->toArray();
|
||||
|
||||
$address = $this->customerAddress->find($id);
|
||||
|
||||
if ( $address ) {
|
||||
|
||||
$this->customerAddress->update($data, $id);
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-update'));
|
||||
|
||||
return redirect()->route('admin.customer.addresses.index', ['id' => $address->customer_id]);
|
||||
}
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->customerAddress->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-delete'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mass Delete the customer's addresses
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function massDestroy($id)
|
||||
{
|
||||
$addressIds = explode(',', request()->input('indexes'));
|
||||
|
||||
foreach ($addressIds as $addressId) {
|
||||
$this->customerAddress->delete($addressId);
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-mass-delete'));
|
||||
|
||||
return redirect()->route($this->_config['redirect'], ['id' => $id]);
|
||||
}
|
||||
}
|
||||
|
|
@ -82,6 +82,36 @@ Route::group(['middleware' => ['web']], function () {
|
|||
'view' => 'admin::customers.reviews.index'
|
||||
])->name('admin.customer.review.index');
|
||||
|
||||
//Customer's addresses routes
|
||||
Route::get('customers/{id}/addresses', 'Webkul\Admin\Http\Controllers\Customer\AddressController@index')->defaults('_config', [
|
||||
'view' => 'admin::customers.addresses.index'
|
||||
])->name('admin.customer.addresses.index');
|
||||
|
||||
Route::get('customers/{id}/addresses/create', 'Webkul\Admin\Http\Controllers\Customer\AddressController@create')->defaults('_config',[
|
||||
'view' => 'admin::customers.addresses.create'
|
||||
])->name('admin.customer.addresses.create');
|
||||
|
||||
Route::post('customers/{id}/addresses/create', 'Webkul\Admin\Http\Controllers\Customer\AddressController@store')->defaults('_config',[
|
||||
'redirect' => 'admin.customer.addresses.index'
|
||||
])->name('admin.customer.addresses.store');
|
||||
|
||||
Route::get('customers/addresses/edit/{id}', 'Webkul\Admin\Http\Controllers\Customer\AddressController@edit')->defaults('_config',[
|
||||
'view' => 'admin::customers.addresses.edit'
|
||||
])->name('admin.customer.addresses.edit');
|
||||
|
||||
Route::put('customers/addresses/edit/{id}', 'Webkul\Admin\Http\Controllers\Customer\AddressController@update')->defaults('_config', [
|
||||
'redirect' => 'admin.customer.addresses.index'
|
||||
])->name('admin.customer.addresses.update');
|
||||
|
||||
Route::post('customers/addresses/delete/{id}', 'Webkul\Admin\Http\Controllers\Customer\AddressController@destroy')->defaults('_config', [
|
||||
'redirect' => 'admin.customer.addresses.index'
|
||||
])->name('admin.customer.addresses.delete');
|
||||
|
||||
//mass destroy
|
||||
Route::post('customers/{id}/addresses', 'Webkul\Admin\Http\Controllers\Customer\AddressController@massDestroy')->defaults('_config', [
|
||||
'redirect' => 'admin.customer.addresses.index'
|
||||
])->name('admin.customer.addresses.massdelete');
|
||||
|
||||
// Configuration routes
|
||||
Route::get('configuration/{slug?}/{slug2?}', 'Webkul\Admin\Http\Controllers\ConfigurationController@index')->defaults('_config', [
|
||||
'view' => 'admin::configuration.index'
|
||||
|
|
|
|||
|
|
@ -161,6 +161,8 @@ return [
|
|||
'hostname' => 'Hostname',
|
||||
'email' => 'Email',
|
||||
'group' => 'Group',
|
||||
'phone' => 'Phone',
|
||||
'gender' => 'Gender',
|
||||
'title' => 'Title',
|
||||
'layout' => 'Layout',
|
||||
'url-key' => 'URL Key',
|
||||
|
|
@ -849,6 +851,35 @@ return [
|
|||
'yes' => 'Yes'
|
||||
],
|
||||
|
||||
'addresses' => [
|
||||
'title' => ':customer_name\'s Addresses List',
|
||||
'create-title' => 'Create Customer\'s Address',
|
||||
'edit-title' => 'Update Customer\'s Address',
|
||||
'title-orders' => ':customer_name\'s Orders List',
|
||||
'address-list' => 'Address\'s List',
|
||||
'order-list' => 'Order\'s List',
|
||||
'address-id' => 'Address ID',
|
||||
'address-1' => 'Address 1',
|
||||
'city' => 'City',
|
||||
'state-name' => 'State',
|
||||
'country-name' => 'Country',
|
||||
'postcode' => 'Post Code',
|
||||
'default-address' => 'Default Address',
|
||||
'yes' => 'Yes',
|
||||
'not-approved' => 'Not Approved',
|
||||
'no' => 'No',
|
||||
'dash' => '-',
|
||||
'delete' => 'Delete',
|
||||
'create-btn-title' => 'Add Address',
|
||||
'save-btn-title' => 'Save Address',
|
||||
'general' => 'General',
|
||||
'success-create' => 'Success: Customer address created successfully.',
|
||||
'success-update' => 'Success: Customer address updated successfully.',
|
||||
'success-delete' => 'Success: Customer address deleted successfully.',
|
||||
'success-mass-delete' => 'Success: selected addresses deleted successfully.',
|
||||
'error-create' => 'Error: Customer address not created.',
|
||||
],
|
||||
|
||||
'note' => [
|
||||
'title' => 'Add Note',
|
||||
'save-note' => 'Save Note',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
@extends('admin::layouts.content')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('admin::app.customers.addresses.create-title') }}
|
||||
@stop
|
||||
|
||||
|
||||
@section('content-wrapper')
|
||||
|
||||
<div class="content full-page">
|
||||
{!! view_render_event('admin.customer.addresses.create.before') !!}
|
||||
|
||||
<form method="POST" action="{{ route('admin.customer.addresses.store', ['id' => $customer->id]) }}" @submit.prevent="onSubmit">
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>
|
||||
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
|
||||
|
||||
{{ __('admin::app.customers.addresses.create-title') }}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
<button type="submit" class="btn btn-lg btn-primary">
|
||||
{{ __('admin::app.customers.addresses.save-btn-title') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
@csrf()
|
||||
|
||||
<input type="hidden" name="customer_id" value="{{ $customer->id }}">
|
||||
|
||||
<accordian :title="'{{ __('admin::app.customers.addresses.general') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
<div class="control-group" :class="[errors.has('address1[]') ? 'has-error' : '']">
|
||||
<label for="address_0" class="required">{{ __('shop::app.customer.account.address.edit.street-address') }}</label>
|
||||
<input type="text" class="control" name="address1[]" id="address_0" v-validate="'required'" value="{{ old('address1') }}" data-vv-as=""{{ __('shop::app.customer.account.address.create.street-address') }}"">
|
||||
<span class="control-error" v-if="errors.has('address1[]')">@{{ errors.first('address1[]') }}</span>
|
||||
</div>
|
||||
|
||||
@if (core()->getConfigData('customer.settings.address.street_lines') && core()->getConfigData('customer.settings.address.street_lines') > 1)
|
||||
<div class="control-group" style="margin-top: -25px;">
|
||||
@for ($i = 1; $i < core()->getConfigData('customer.settings.address.street_lines'); $i++)
|
||||
<input type="text" class="control" name="address1[{{ $i }}]" id="address_{{ $i }}">
|
||||
@endfor
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="control-group" :class="[errors.has('city') ? 'has-error' : '']">
|
||||
<label for="city" class="required">{{ __('shop::app.customer.account.address.create.city') }}</label>
|
||||
<input type="text" class="control" name="city" v-validate="'required|alpha_spaces'" value="{{ old('city') }}" data-vv-as=""{{ __('shop::app.customer.account.address.create.city') }}"">
|
||||
<span class="control-error" v-if="errors.has('city')">@{{ errors.first('city') }}</span>
|
||||
</div>
|
||||
|
||||
@include ('shop::customers.account.address.country-state', ['countryCode' => old('country') ?? '', 'stateCode' => old('state') ?? ''])
|
||||
|
||||
<div class="control-group" :class="[errors.has('postcode') ? 'has-error' : '']">
|
||||
<label for="postcode" class="required">{{ __('shop::app.customer.account.address.create.postcode') }}</label>
|
||||
<input type="text" class="control" name="postcode" v-validate="'required'" value="{{ old('postcode') }}" data-vv-as=""{{ __('shop::app.customer.account.address.create.postcode') }}"">
|
||||
<span class="control-error" v-if="errors.has('postcode')">@{{ errors.first('postcode') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('phone') ? 'has-error' : '']">
|
||||
<label for="phone" class="required">{{ __('shop::app.customer.account.address.create.phone') }}</label>
|
||||
<input type="text" class="control" name="phone" v-validate="'required'" value="{{ old('phone') }}" data-vv-as=""{{ __('shop::app.customer.account.address.create.phone') }}"">
|
||||
<span class="control-error" v-if="errors.has('phone')">@{{ errors.first('phone') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<span class="checkbox">
|
||||
<input type="checkbox" class="control" id="default_address" name="default_address" {{ old('default_address') ? 'checked' : '' }} >
|
||||
|
||||
<label class="checkbox-view" for="default_address"></label>
|
||||
{{ __('admin::app.customers.addresses.default-address') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{!! view_render_event('admin.customer.addresses.create.after') !!}
|
||||
</div>
|
||||
@stop
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
@extends('admin::layouts.content')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('admin::app.customers.addresses.edit-title') }}
|
||||
@stop
|
||||
|
||||
|
||||
@section('content-wrapper')
|
||||
|
||||
<div class="content full-page">
|
||||
{!! view_render_event('admin.customer.addresses.edit.before', ['address' => $address]) !!}
|
||||
|
||||
<form method="post" action="{{ route('admin.customer.addresses.update', $address->id) }}" @submit.prevent="onSubmit">
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>{{ __('admin::app.customers.addresses.edit-title') }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
<button type="submit" class="btn btn-primary btn-lg">
|
||||
{{ __('admin::app.customers.addresses.save-btn-title') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
@csrf()
|
||||
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
|
||||
<input type="hidden" name="customer_id" value="{{ $address->customer_id }}">
|
||||
|
||||
<accordian :title="'{{ __('admin::app.customers.addresses.general') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
<?php $addresses = explode(PHP_EOL, $address->address1); ?>
|
||||
|
||||
<div class="control-group" :class="[errors.has('address1[]') ? 'has-error' : '']">
|
||||
<label for="address_0" class="required">{{ __('shop::app.customer.account.address.edit.street-address') }}</label>
|
||||
<input type="text" class="control" name="address1[]" id="address_0" v-validate="'required'" value="{{ isset($addresses[0]) ? $addresses[0] : '' }}" data-vv-as=""{{ __('shop::app.customer.account.address.create.street-address') }}"">
|
||||
<span class="control-error" v-if="errors.has('address1[]')">@{{ errors.first('address1[]') }}</span>
|
||||
</div>
|
||||
|
||||
@if (core()->getConfigData('customer.settings.address.street_lines') && core()->getConfigData('customer.settings.address.street_lines') > 1)
|
||||
<div class="control-group" style="margin-top: -25px;">
|
||||
@for ($i = 1; $i < core()->getConfigData('customer.settings.address.street_lines'); $i++)
|
||||
<input type="text" class="control" name="address1[{{ $i }}]" id="address_{{ $i }}" value="{{ isset($addresses[$i]) ? $addresses[$i] : '' }}">
|
||||
@endfor
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="control-group" :class="[errors.has('city') ? 'has-error' : '']">
|
||||
<label for="city" class="required">{{ __('shop::app.customer.account.address.create.city') }}</label>
|
||||
<input type="text" class="control" name="city" v-validate="'required|alpha_spaces'" value="{{ $address->city }}" data-vv-as=""{{ __('shop::app.customer.account.address.create.city') }}"">
|
||||
<span class="control-error" v-if="errors.has('city')">@{{ errors.first('city') }}</span>
|
||||
</div>
|
||||
|
||||
@include ('shop::customers.account.address.country-state', ['countryCode' => old('country') ?? $address->country, 'stateCode' => old('state') ?? $address->state])
|
||||
|
||||
<div class="control-group" :class="[errors.has('postcode') ? 'has-error' : '']">
|
||||
<label for="postcode" class="required">{{ __('shop::app.customer.account.address.create.postcode') }}</label>
|
||||
<input type="text" class="control" name="postcode" v-validate="'required'" value="{{ $address->postcode }}" data-vv-as=""{{ __('shop::app.customer.account.address.create.postcode') }}"">
|
||||
<span class="control-error" v-if="errors.has('postcode')">@{{ errors.first('postcode') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('phone') ? 'has-error' : '']">
|
||||
<label for="phone" class="required">{{ __('shop::app.customer.account.address.create.phone') }}</label>
|
||||
<input type="text" class="control" name="phone" v-validate="'required'" value="{{ $address->phone }}" data-vv-as=""{{ __('shop::app.customer.account.address.create.phone') }}"">
|
||||
<span class="control-error" v-if="errors.has('phone')">@{{ errors.first('phone') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<span class="checkbox">
|
||||
<input type="checkbox" class="control" id="default_address" name="default_address" {{ $address->default_address ? 'checked' : '' }} >
|
||||
|
||||
<label class="checkbox-view" for="default_address"></label>
|
||||
{{ __('admin::app.customers.addresses.default-address') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
</form>
|
||||
|
||||
|
||||
{!! view_render_event('admin.customer.addresses.edit.after', ['address' => $address]) !!}
|
||||
</div>
|
||||
@stop
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
@extends('admin::layouts.content')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('admin::app.customers.addresses.title', ['customer_name' => $customer->first_name . ' ' . $customer->last_name]) }}
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
<div class="content">
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>{{ __('admin::app.customers.addresses.title', ['customer_name' => $customer->first_name . ' ' . $customer->last_name]) }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
<a href="{{ route('admin.customer.addresses.create', ['id' => $customer->id]) }}" class="btn btn-lg btn-primary">
|
||||
{{ __('admin::app.customers.addresses.create-btn-title') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.admin.customer.addresses.list.before') !!}
|
||||
|
||||
<div class="page-content">
|
||||
|
||||
{!! app('Webkul\Admin\DataGrids\AddressDataGrid')->render() !!}
|
||||
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.admin.customer.addresses.list.after') !!}
|
||||
</div>
|
||||
@stop
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
@extends('address::admin.layouts.content')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('address::app.admin.addresses.title-orders', ['customer_name' => $customer->first_name . ' ' . $customer->last_name]) }}
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="content">
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>
|
||||
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
|
||||
|
||||
{{ __('address::app.admin.addresses.title-orders', ['customer_name' => $customer->first_name . ' ' . $customer->last_name]) }}
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li><a href="{{ route('admin.address.addresses.index', ['id' => $customer->id]) }}">{{ __('address::app.admin.addresses.address-list') }}</a></li>
|
||||
|
||||
<li class="active"><a href="{{ route('admin.address.orders.index', ['id' => $customer->id]) }}">{{ __('address::app.admin.addresses.order-list') }}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{!! app('Webkul\Address\DataGrids\Admin\OrderDataGrid')->render() !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@stop
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Webkul\Customer\Repositories;
|
||||
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
/**
|
||||
* Customer Reposotory
|
||||
|
|
@ -23,4 +24,64 @@ class CustomerAddressRepository extends Repository
|
|||
{
|
||||
return 'Webkul\Customer\Contracts\CustomerAddress';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
Event::fire('customer.addresses.create.before');
|
||||
|
||||
if ( isset($data['default_address']) ) {
|
||||
$data['default_address'] = 1;
|
||||
} else {
|
||||
$data['default_address'] = 0;
|
||||
}
|
||||
|
||||
$default_address = $this->findWhere(['customer_id' => $data['customer_id'], 'default_address' => 1])->first();
|
||||
|
||||
if ( isset($default_address->id) && $data['default_address'] ) {
|
||||
$default_address->update(['default_address' => 0]);
|
||||
}
|
||||
|
||||
$address = $this->model->create($data);
|
||||
|
||||
Event::fire('customer.addresses.create.after', $address);
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(array $data, $id)
|
||||
{
|
||||
$address = $this->find($id);
|
||||
|
||||
Event::fire('customer.addresses.update.before', $id);
|
||||
|
||||
if (isset($data['default_address']) ) {
|
||||
$data['default_address'] = 1;
|
||||
} else {
|
||||
$data['default_address'] = 0;
|
||||
}
|
||||
|
||||
$default_address = $this->findWhere(['customer_id' => $address->customer_id, 'default_address' => 1])->first();
|
||||
|
||||
if ( isset($default_address->id) && $data['default_address'] ) {
|
||||
if ( $default_address->id != $address->id ) {
|
||||
$default_address->update(['default_address' => 0]);
|
||||
}
|
||||
$address->update($data);
|
||||
} else {
|
||||
$address->update($data);
|
||||
}
|
||||
|
||||
Event::fire('customer.addresses.update.after', $id);
|
||||
|
||||
return $address;
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51.1 (57501) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>Listing</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Listing" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
|
||||
<g id="Group-2" transform="translate(6.000000, 4.000000)" stroke="#8E8E8E" stroke-width="2">
|
||||
<g id="Group">
|
||||
<path d="M5.41666667,1.66666667 L13,1.66666667" id="Path-6"></path>
|
||||
<path d="M0,1.66666667 L1.08333333,1.66666667" id="Path-6-Copy"></path>
|
||||
</g>
|
||||
<g id="Group-Copy" transform="translate(0.000000, 4.000000)">
|
||||
<path d="M5.41666667,1.66666667 L13,1.66666667" id="Path-6"></path>
|
||||
<path d="M0,1.66666667 L1.08333333,1.66666667" id="Path-6-Copy"></path>
|
||||
</g>
|
||||
<g id="Group-Copy-2" transform="translate(0.000000, 8.000000)">
|
||||
<path d="M5.41666667,1.66666667 L13,1.66666667" id="Path-6"></path>
|
||||
<path d="M0,1.66666667 L1.08333333,1.66666667" id="Path-6-Copy"></path>
|
||||
</g>
|
||||
<g id="Group-Copy-3" transform="translate(0.000000, 12.000000)">
|
||||
<path d="M5.41666667,1.66666667 L13,1.66666667" id="Path-6"></path>
|
||||
<path d="M0,1.66666667 L1.08333333,1.66666667" id="Path-6-Copy"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"/js/ui.js": "/js/ui.js?id=62a1f3ccf04e55a10ae8",
|
||||
"/css/ui.css": "/css/ui.css?id=485e4b6533049df9136b"
|
||||
"/js/ui.js": "/js/ui.js?id=6d036cbd57bda8520f6c",
|
||||
"/css/ui.css": "/css/ui.css?id=b61e212bdad67ef040f5"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51.1 (57501) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>Listing</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Listing" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
|
||||
<g id="Group-2" transform="translate(6.000000, 4.000000)" stroke="#8E8E8E" stroke-width="2">
|
||||
<g id="Group">
|
||||
<path d="M5.41666667,1.66666667 L13,1.66666667" id="Path-6"></path>
|
||||
<path d="M0,1.66666667 L1.08333333,1.66666667" id="Path-6-Copy"></path>
|
||||
</g>
|
||||
<g id="Group-Copy" transform="translate(0.000000, 4.000000)">
|
||||
<path d="M5.41666667,1.66666667 L13,1.66666667" id="Path-6"></path>
|
||||
<path d="M0,1.66666667 L1.08333333,1.66666667" id="Path-6-Copy"></path>
|
||||
</g>
|
||||
<g id="Group-Copy-2" transform="translate(0.000000, 8.000000)">
|
||||
<path d="M5.41666667,1.66666667 L13,1.66666667" id="Path-6"></path>
|
||||
<path d="M0,1.66666667 L1.08333333,1.66666667" id="Path-6-Copy"></path>
|
||||
</g>
|
||||
<g id="Group-Copy-3" transform="translate(0.000000, 12.000000)">
|
||||
<path d="M5.41666667,1.66666667 L13,1.66666667" id="Path-6"></path>
|
||||
<path d="M0,1.66666667 L1.08333333,1.66666667" id="Path-6-Copy"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -449,6 +449,10 @@ h5 {
|
|||
|
||||
&.actions {
|
||||
|
||||
.action {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.icon {
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
|
|
|
|||
|
|
@ -236,6 +236,12 @@
|
|||
height: 24px;
|
||||
}
|
||||
|
||||
.list-icon {
|
||||
background-image: url("../images/Icon-Listing.svg");
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.active {
|
||||
.dashboard-icon {
|
||||
background-image: url("../images/Icon-Dashboard-Active.svg");
|
||||
|
|
|
|||
Loading…
Reference in New Issue