forked from bagisto/laravel-pwa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…isto#188 bagisto#186 Fixed
- Loading branch information
1 parent
ba6920e
commit 1bb932b
Showing
9 changed files
with
144 additions
and
12 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"/js/app.js": "/js/app.js?id=4da03409f21eb650589d", | ||
"/js/app.js": "/js/app.js?id=899a90acfbec8ab03f16", | ||
"/css/pwa-admin.css": "/css/pwa-admin.css?id=7073d876ccd90f556cb1", | ||
"/css/pwa.css": "/css/pwa.css?id=985298ea84b30351141c" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters