sarga/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php

304 lines
8.8 KiB
PHP
Raw Normal View History

2018-09-08 08:41:36 +00:00
<?php
2018-10-17 07:40:08 +00:00
namespace Webkul\Admin\Http\Controllers\Customer;
2018-09-08 08:41:36 +00:00
use Illuminate\Support\Facades\Event;
2018-10-22 05:47:42 +00:00
use Webkul\Admin\Http\Controllers\Controller;
2019-07-01 11:33:36 +00:00
use Webkul\Customer\Repositories\CustomerRepository;
2020-06-15 02:29:00 +00:00
use Webkul\Customer\Repositories\CustomerAddressRepository;
2019-07-01 11:33:36 +00:00
use Webkul\Customer\Repositories\CustomerGroupRepository;
use Webkul\Core\Repositories\ChannelRepository;
2020-06-15 02:29:00 +00:00
use Webkul\Admin\Mail\NewCustomerNotification;
use Mail;
2018-09-08 08:41:36 +00:00
class CustomerController extends Controller
{
/**
2018-09-11 04:11:48 +00:00
* Contains route related configuration
2018-09-08 08:41:36 +00:00
*
2018-09-11 04:11:48 +00:00
* @var array
2018-09-08 08:41:36 +00:00
*/
protected $_config;
2018-09-11 04:11:48 +00:00
/**
* CustomerRepository object
*
2020-03-05 13:37:08 +00:00
* @var \Webkul\Customer\Repositories\CustomerRepository
2018-09-11 04:11:48 +00:00
*/
2019-07-01 11:33:36 +00:00
protected $customerRepository;
2018-09-11 04:11:48 +00:00
2020-06-15 02:29:00 +00:00
/**
* CustomerAddress Repository object
*
* @var \Webkul\Customer\Repositories\CustomerAddressRepository
*/
protected $customerAddressRepository;
2020-01-14 09:49:22 +00:00
/**
2018-09-11 04:11:48 +00:00
* CustomerGroupRepository object
*
2020-03-05 13:37:08 +00:00
* @var \Webkul\Customer\Repositories\CustomerGroupRepository
2018-09-11 04:11:48 +00:00
*/
2019-07-01 11:33:36 +00:00
protected $customerGroupRepository;
2018-09-11 04:11:48 +00:00
2020-01-14 09:49:22 +00:00
/**
2018-10-22 05:47:42 +00:00
* ChannelRepository object
*
2020-03-05 13:37:08 +00:00
* @var \Webkul\Core\Repositories\ChannelRepository
2018-10-22 05:47:42 +00:00
*/
2019-07-01 11:33:36 +00:00
protected $channelRepository;
2018-10-22 05:47:42 +00:00
2019-04-03 07:04:35 +00:00
/**
2018-09-11 04:11:48 +00:00
* Create a new controller instance.
*
2020-03-05 14:19:14 +00:00
* @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository
2020-06-15 02:29:00 +00:00
* @param \Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository
2020-03-05 13:37:08 +00:00
* @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository
2020-03-05 14:19:14 +00:00
* @param \Webkul\Core\Repositories\ChannelRepository $channelRepository
2018-09-11 04:11:48 +00:00
*/
2019-07-01 11:33:36 +00:00
public function __construct(
CustomerRepository $customerRepository,
2020-06-15 02:29:00 +00:00
CustomerAddressRepository $customerAddressRepository,
2019-07-01 11:33:36 +00:00
CustomerGroupRepository $customerGroupRepository,
ChannelRepository $channelRepository
2020-06-15 02:29:00 +00:00
)
2020-07-30 07:10:15 +00:00
2020-06-15 02:29:00 +00:00
{
$this->_config = request('_config');
$this->middleware('admin');
$this->customerRepository = $customerRepository;
2020-07-30 07:10:15 +00:00
2020-06-15 02:29:00 +00:00
$this->customerAddressRepository = $customerAddressRepository;
$this->customerGroupRepository = $customerGroupRepository;
$this->channelRepository = $channelRepository;
}
2018-09-08 08:41:36 +00:00
/**
* Display a listing of the resource.
*
2019-08-19 09:30:24 +00:00
* @return \Illuminate\View\View
2020-01-14 09:49:22 +00:00
*/
2018-09-08 08:41:36 +00:00
public function index()
{
return view($this->_config['view']);
}
2020-01-14 09:49:22 +00:00
/**
2018-09-11 04:11:48 +00:00
* Show the form for creating a new resource.
*
2019-08-19 09:30:24 +00:00
* @return \Illuminate\View\View
2018-09-11 04:11:48 +00:00
*/
public function create()
{
2019-07-01 11:33:36 +00:00
$customerGroup = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
2018-09-11 04:11:48 +00:00
2019-07-01 11:33:36 +00:00
$channelName = $this->channelRepository->all();
2018-10-22 05:47:42 +00:00
2020-01-14 09:49:22 +00:00
return view($this->_config['view'], compact('customerGroup', 'channelName'));
2018-09-11 04:11:48 +00:00
}
2020-01-14 09:49:22 +00:00
/**
2018-09-11 04:11:48 +00:00
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\Response
*/
2018-10-22 05:47:42 +00:00
public function store()
2018-09-11 04:11:48 +00:00
{
2018-10-22 05:47:42 +00:00
$this->validate(request(), [
2020-01-14 09:49:22 +00:00
'first_name' => 'string|required',
'last_name' => 'string|required',
'gender' => 'required',
'email' => 'required|unique:customers,email',
'date_of_birth' => 'date|before:today',
2018-09-11 04:11:48 +00:00
]);
2019-02-13 12:12:07 +00:00
$data = request()->all();
2018-09-11 04:11:48 +00:00
2020-01-14 09:49:22 +00:00
$password = rand(100000, 10000000);
2018-09-11 04:11:48 +00:00
$data['password'] = bcrypt($password);
$data['is_verified'] = 1;
2018-09-11 04:11:48 +00:00
Event::dispatch('customer.registration.before');
2019-08-19 10:31:38 +00:00
$customer = $this->customerRepository->create($data);
Event::dispatch('customer.registration.after', $customer);
2019-08-20 11:18:11 +00:00
try {
2020-02-17 15:52:58 +00:00
$configKey = 'emails.general.notifications.emails.general.notifications.customer';
if (core()->getConfigData($configKey)) {
Mail::queue(new NewCustomerNotification($customer, $password));
}
2019-08-20 11:18:11 +00:00
} catch (\Exception $e) {
2020-01-27 16:06:03 +00:00
report($e);
2019-08-20 11:18:11 +00:00
}
2018-09-11 04:11:48 +00:00
2019-01-16 08:38:39 +00:00
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Customer']));
2018-09-11 04:11:48 +00:00
return redirect()->route($this->_config['redirect']);
}
2018-09-08 08:41:36 +00:00
/**
* Show the form for editing the specified resource.
*
2020-03-05 13:37:08 +00:00
* @param int $id
2019-08-19 09:30:24 +00:00
* @return \Illuminate\View\View
2018-09-08 08:41:36 +00:00
*/
public function edit($id)
{
2019-07-01 11:33:36 +00:00
$customer = $this->customerRepository->findOrFail($id);
2020-06-15 02:29:00 +00:00
$address = $this->customerAddressRepository->find($id);
2019-07-01 11:33:36 +00:00
$customerGroup = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
$channelName = $this->channelRepository->all();
2018-10-22 05:47:42 +00:00
2020-06-15 02:29:00 +00:00
return view($this->_config['view'], compact('customer', 'address', 'customerGroup', 'channelName'));
2018-09-08 08:41:36 +00:00
}
2020-01-14 09:49:22 +00:00
/**
2018-09-08 08:41:36 +00:00
* Update the specified resource in storage.
*
2020-03-05 13:37:08 +00:00
* @param int $id
2018-09-08 08:41:36 +00:00
* @return \Illuminate\Http\Response
*/
2019-07-01 11:33:36 +00:00
public function update($id)
2018-09-08 08:41:36 +00:00
{
2018-10-22 05:47:42 +00:00
$this->validate(request(), [
2020-01-14 09:49:22 +00:00
'first_name' => 'string|required',
'last_name' => 'string|required',
'gender' => 'required',
'email' => 'required|unique:customers,email,' . $id,
'date_of_birth' => 'date|before:today',
2018-10-12 11:31:14 +00:00
]);
2018-09-08 08:41:36 +00:00
2020-02-11 12:26:25 +00:00
$data = request()->all();
$data['status'] = ! isset($data['status']) ? 0 : 1;
Event::dispatch('customer.update.before');
$customer = $this->customerRepository->update($data, $id);
Event::dispatch('customer.update.after', $customer);
2018-09-08 08:41:36 +00:00
2019-01-16 08:38:39 +00:00
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Customer']));
2018-09-08 08:41:36 +00:00
return redirect()->route($this->_config['redirect']);
}
2018-10-17 10:47:03 +00:00
/**
* Remove the specified resource from storage.
*
2020-03-05 13:37:08 +00:00
* @param int $id
2018-10-17 10:47:03 +00:00
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
2019-07-01 11:33:36 +00:00
$customer = $this->customerRepository->findorFail($id);
2018-10-17 10:47:03 +00:00
2019-04-09 01:01:52 +00:00
try {
2018-10-17 10:47:03 +00:00
2020-08-04 12:30:56 +00:00
if (! $this->customerRepository->checkIfCustomerHasOrderPendingOrProcessing($customer)) {
2020-07-30 07:10:15 +00:00
$this->customerRepository->delete($id);
} else {
2020-08-04 12:30:56 +00:00
2020-08-10 15:22:03 +00:00
session()->flash('error', trans('admin::app.response.order-pending', ['name' => 'Customer']));
2020-07-30 07:10:15 +00:00
return response()->json(['message' => false], 400);
}
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Customer']));
return response()->json(['message' => true], 200);
2020-01-14 09:49:22 +00:00
} catch (\Exception $e) {
2020-07-30 07:10:15 +00:00
2019-04-09 01:01:52 +00:00
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Customer']));
}
return response()->json(['message' => false], 400);
2018-10-17 10:47:03 +00:00
}
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
/**
* To load the note taking screen for the customers
*
2020-03-05 13:37:08 +00:00
* @param int $id
2019-08-19 09:30:24 +00:00
* @return \Illuminate\View\View
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
*/
public function createNote($id)
{
2019-07-01 11:33:36 +00:00
$customer = $this->customerRepository->find($id);
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
return view($this->_config['view'])->with('customer', $customer);
}
/**
* To store the response of the note in storage
*
2020-03-05 05:34:57 +00:00
* @return \Illuminate\Http\Response
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
*/
public function storeNote()
{
$this->validate(request(), [
2020-01-14 09:49:22 +00:00
'notes' => 'string|nullable',
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
]);
2019-07-01 11:33:36 +00:00
$customer = $this->customerRepository->find(request()->input('_customer'));
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
2020-02-19 10:26:44 +00:00
$noteTaken = $customer->update(['notes' => request()->input('notes')]);
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
if ($noteTaken) {
session()->flash('success', 'Note taken');
} else {
session()->flash('error', 'Note cannot be taken');
}
return redirect()->route($this->_config['redirect']);
}
/**
* To mass update the customer
*
2020-03-05 05:34:57 +00:00
* @return \Illuminate\Http\Response
*/
public function massUpdate()
{
$customerIds = explode(',', request()->input('indexes'));
$updateOption = request()->input('update-options');
foreach ($customerIds as $customerId) {
2019-07-01 11:33:36 +00:00
$customer = $this->customerRepository->find($customerId);
2020-02-19 10:26:44 +00:00
$customer->update(['status' => $updateOption]);
}
session()->flash('success', trans('admin::app.customers.customers.mass-update-success'));
return redirect()->back();
}
/**
* To mass delete the customer
*
2020-03-05 05:34:57 +00:00
* @return \Illuminate\Http\Response
*/
public function massDestroy()
{
$customerIds = explode(',', request()->input('indexes'));
2020-07-31 08:16:29 +00:00
if (!$this->customerRepository->checkBulkCustomerIfTheyHaveOrderPendingOrProcessing($customerIds)) {
foreach ($customerIds as $customerId) {
$this->customerRepository->deleteWhere(['id' => $customerId]);
}
session()->flash('success', trans('admin::app.customers.customers.mass-destroy-success'));
2020-07-31 08:16:29 +00:00
return redirect()->back();
}
2020-07-31 08:16:29 +00:00
session()->flash('error', trans('admin::app.response.order-pending', ['name' => 'Customers']));
return redirect()->back();
}
2019-04-09 01:01:52 +00:00
}