Improved customer package code style

This commit is contained in:
Jitendra Singh 2020-02-19 19:18:54 +05:30
parent 5fb33d4fc9
commit 9e7e939479
10 changed files with 26 additions and 19 deletions

View File

@ -36,14 +36,15 @@ class Wishlist
if (auth()->guard('customer')->user()) {
$wishlist = $this->wishlistRepository->findOneWhere([
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $product->product_id,
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $product->product_id,
'customer_id' => auth()->guard('customer')->user()->id
]);
}
if ($wishlist)
if ($wishlist) {
return true;
}
return false;
}

View File

@ -182,8 +182,9 @@ class AddressController extends Controller
*/
public function makeDefault($id)
{
if ($default = $this->customer->default_address)
if ($default = $this->customer->default_address) {
$this->customerAddressRepository->find($default->id)->update(['default_address' => 0]);
}
if ($address = $this->customerAddressRepository->find($id)) {
$address->update(['default_address' => 1]);
@ -208,8 +209,9 @@ class AddressController extends Controller
'customer_id' => auth()->guard('customer')->user()->id,
]);
if (! $address)
if (! $address) {
abort(404);
}
$this->customerAddressRepository->delete($id);

View File

@ -59,8 +59,8 @@ class ResetPasswordController extends Controller
{
try {
$this->validate(request(), [
'token' => 'required',
'email' => 'required|email',
'token' => 'required',
'email' => 'required|email',
'password' => 'required|confirmed|min:6',
]);

View File

@ -54,7 +54,7 @@ class SessionController extends Controller
public function create()
{
$this->validate(request(), [
'email' => 'required|email',
'email' => 'required|email',
'password' => 'required'
]);

View File

@ -82,14 +82,14 @@ class WishlistController extends Controller
return redirect()->back();
$data = [
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $itemId,
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $itemId,
'customer_id' => auth()->guard('customer')->user()->id
];
$checked = $this->wishlistRepository->findWhere([
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $itemId,
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $itemId,
'customer_id' => auth()->guard('customer')->user()->id
]);
@ -152,12 +152,13 @@ class WishlistController extends Controller
public function move($itemId)
{
$wishlistItem = $this->wishlistRepository->findOneWhere([
'id' => $itemId,
'id' => $itemId,
'customer_id' => auth()->guard('customer')->user()->id
]);
if (! $wishlistItem)
if (! $wishlistItem) {
abort(404);
}
try {
$result = Cart::moveToCart($wishlistItem);

View File

@ -20,9 +20,9 @@ class CustomerAddress extends Model implements CustomerAddressContract
'city',
'postcode',
'phone',
'default_address',
'first_name',
'last_name',
'default_address',
'first_name',
'last_name',
];
/**

View File

@ -24,7 +24,7 @@ class CustomerResetPassword extends ResetPassword
->subject(__('shop::app.mail.forget-password.subject') )
->view('shop::emails.customer.forget-password', [
'user_name' => $notifiable->name,
'token' => $this->token
'token' => $this->token
]);
}
}

View File

@ -72,6 +72,7 @@ class CustomerAddressRepository extends Repository
if ($default_address->id != $address->id) {
$default_address->update(['default_address' => 0]);
}
$address->update($data);
} else {
$address->update($data);

View File

@ -69,7 +69,7 @@ class WishlistRepository extends Repository
*/
public function getCustomerWhishlist() {
return $this->model->where([
'channel_id' => core()->getCurrentChannel()->id,
'channel_id' => core()->getCurrentChannel()->id,
'customer_id' => auth()->guard('customer')->user()->id
])->paginate(5);
}

View File

@ -64,6 +64,7 @@ class VatValidator
public function validate(string $vatNumber): bool
{
$vatNumber = $this->vatCleaner($vatNumber);
list($country, $number) = $this->splitVat($vatNumber);
if (! isset(self::$pattern_expression[$country])) {
@ -81,6 +82,7 @@ class VatValidator
private function vatCleaner(string $vatNumber): string
{
$vatNumber_no_spaces = trim($vatNumber);
return strtoupper($vatNumber_no_spaces);
}