Skip to content

Commit

Permalink
Merge pull request #185 from vishal-webkul/v1.3.0
Browse files Browse the repository at this point in the history
Compatible with v1.3.0
  • Loading branch information
vivek-webkul authored Mar 17, 2021
2 parents 90e304e + 65bfb36 commit a510494
Show file tree
Hide file tree
Showing 44 changed files with 907 additions and 51 deletions.
2 changes: 1 addition & 1 deletion publishable/assets/css/pwa.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions publishable/assets/images/camera.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion publishable/assets/js/app.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions publishable/assets/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"/js/app.js": "/js/app.js?id=0d10c953b55aa5b3686d",
"/js/app.js": "/js/app.js?id=8c123f54f03db571ee75",
"/css/pwa-admin.css": "/css/pwa-admin.css?id=7073d876ccd90f556cb1",
"/css/pwa.css": "/css/pwa.css?id=985298ea84b30351141c"
"/css/pwa.css": "/css/pwa.css?id=c95e523dd6940325d46a"
}
6 changes: 3 additions & 3 deletions src/Http/Controllers/Admin/LayoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public function index()
*/
public function store(Request $request)
{
$this->validate(request(), [
'home_page_content' => 'required',
]);
// $this->validate(request(), [
// 'home_page_content' => 'required',
// ]);

$existing = $this->pwaLayoutRepository->first();

Expand Down
88 changes: 88 additions & 0 deletions src/Http/Controllers/Shop/AddressController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

namespace Webkul\PWA\Http\Controllers\Shop;

use Webkul\Customer\Repositories\CustomerAddressRepository;
use Webkul\API\Http\Controllers\Shop\Controller;
use Webkul\API\Http\Resources\Customer\CustomerAddress as CustomerAddressResource;

class AddressController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;

/**
* Contains route related configuration
*
* @var array
*/
protected $_config;

/**
* CustomerAddressRepository object
*
* @var \Webkul\Customer\Repositories\CustomerAddressRepository
*/
protected $customerAddressRepository;

/**
* Controller instance
*
* @param Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository
*/
public function __construct(CustomerAddressRepository $customerAddressRepository)
{
$this->guard = request()->has('token') ? 'api' : 'customer';

auth()->setDefaultDriver($this->guard);

// $this->middleware('auth:' . $this->guard);

$this->_config = request('_config');

$this->customerAddressRepository = $customerAddressRepository;
}

/**
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function store()
{
$customer = auth($this->guard)->user();

if (request()->input('address1') && ! is_array(request()->input('address1'))) {
return response()->json([
'message' => 'address1 must be an array.',
]);
}

if (request()->input('address1')) {
request()->merge([
'address1' => implode(PHP_EOL, array_filter(request()->input('address1'))),
'customer_id' => $customer->id,
]);
}

$this->validate(request(), [
'address1' => 'string|required',
'country' => 'string|required',
'state' => 'string|required',
'city' => 'string|required',
'postcode' => 'required',
'phone' => 'required',
]);

$customerAddress = $this->customerAddressRepository->create(request()->all());

return response()->json([
'message' => 'Your address has been created successfully.',
'data' => new CustomerAddressResource($customerAddress),
]);
}
}
15 changes: 12 additions & 3 deletions src/Http/Controllers/Shop/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ public function get()
$redirectToCustomerLogin = true;
}



return response()->json([
'data' => $cart ? new CartResource($cart) : null,
'redirectToCustomerLogin' => $redirectToCustomerLogin ?? false,
Expand All @@ -113,11 +111,22 @@ public function store($id)
if (request()->get('is_buy_now')) {
Event::dispatch('shop.item.buy-now', $id);
}
$data = request()->all();

if (isset($data['links'])) {
$tempLinks = $data['links'];
$temArray = [];
unset($data['links']);
foreach ($tempLinks as $key => $value) {
array_push($temArray, $key);
}
$data['links'] = $temArray;
}

Event::dispatch('checkout.cart.item.add.before', $id);

try {
$result = Cart::addProduct($id, request()->except('_token'));
$result = Cart::addProduct($id, $data);

if (is_array($result) && isset($result['warning'])) {
return response()->json([
Expand Down
35 changes: 34 additions & 1 deletion src/Http/Controllers/Shop/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function __construct(
public function saveAddress(CustomerAddressForm $request)
{
$data = request()->all();

$data['billing']['address1'] = implode(PHP_EOL, array_filter($data['billing']['address1']));
$data['shipping']['address1'] = implode(PHP_EOL, array_filter($data['shipping']['address1']));

Expand Down Expand Up @@ -150,6 +150,39 @@ public function saveShipping()
]);
}

/**
* Check Guest Checkout.
*
* @return \Illuminate\Http\Response
*/
public function isGuestCheckout()
{
$cart = Cart::getCart();

if (! auth()->guard('customer')->check()
&& ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) {
return response()->json([
'data' => [
'status' => false
]
]);
}

if (! auth()->guard('customer')->check() && ! $cart->hasGuestCheckoutItems()) {
return response()->json([
'data' => [
'status' => false
]
]);
}

return response()->json([
'data' => [
'status' => true
]
]);
}

/**
* Saves payment method.
*
Expand Down
45 changes: 45 additions & 0 deletions src/Http/Controllers/Shop/ImageSearchController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Webkul\PWA\Http\Controllers\Shop;

use Illuminate\Http\Request;
use Webkul\API\Http\Controllers\Shop\Controller;
use Webkul\Product\Repositories\SearchRepository;

/**
* Review controller
*
* @author Webkul Software Pvt. Ltd. <[email protected]>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ImageSearchController extends Controller
{
/**
* SearchRepository object
*
* @var \Webkul\Core\Repositories\SearchRepository
*/
protected $searchRepository;

/**
* Controller instance
*
* @param Webkul\Product\Repositories\SearchRepository $searchRepository
*/
public function __construct(SearchRepository $searchRepository)
{
$this->searchRepository = $searchRepository;
}

/**
* Upload image for product search with machine learning
*
* @return \Illuminate\Http\Response
*/
public function upload()
{
$url = $this->searchRepository->uploadSearchImage(request()->all());

return $url;
}
}
Loading

0 comments on commit a510494

Please sign in to comment.