sarga/packages/Webkul/API/Http/Controllers/Customer/AddressController.php

50 lines
1.2 KiB
PHP

<?php
namespace Webkul\API\Http\Controllers\Customer;
use Webkul\API\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Auth;
use Cart;
/**
* Address controller for the APIs Customer Address
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class AddressController extends Controller
{
protected $customer;
public function __construct()
{
if(auth()->guard('customer')->check()) {
$this->customer = auth()->guard('customer')->user();
} else {
return response()->json('Unauthorized', 401);
}
}
/**
* To get the details of user to display on profile
*
* @return response JSON
*/
public function getAddress() {
$addresses = $this->customer->addresses;
return response()->json($addresses, 200);
}
public function getDefaultAddress() {
$defaultAddress = $this->customer->default_address;
if($defaultAddress->count() > 0)
return response()->json($defaultAddress, 200);
else
return response()->json(false, 200);
}
}