This commit is contained in:
parent
75a20bbf1a
commit
7d67dd0d5c
|
|
@ -121,15 +121,15 @@ class CustomerRepo
|
|||
|
||||
/**
|
||||
* @param $customer , Customer对象或id
|
||||
* @param $productId
|
||||
* @param $id
|
||||
* @return void
|
||||
*/
|
||||
public static function removeFromWishlist($customer, $productId)
|
||||
public static function removeFromWishlist($customer, $id)
|
||||
{
|
||||
if (!$customer instanceof Customer) {
|
||||
$customer = Customer::query()->findOrFail($customer);
|
||||
}
|
||||
$customer->wishlists()->where('product_id', $productId)->delete();
|
||||
$customer->wishlists()->where('id', $id)->delete();
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ class WishlistController extends Controller
|
|||
|
||||
public function remove(Request $request): array
|
||||
{
|
||||
$productId = $request->product_id;
|
||||
CustomerRepo::removeFromWishlist(current_customer(), $productId);
|
||||
$id = $request->id;
|
||||
CustomerRepo::removeFromWishlist(current_customer(), $id);
|
||||
|
||||
$wishlists = CustomerRepo::wishlists(current_customer());
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class WishlistDetail extends JsonResource
|
|||
{
|
||||
$data = [
|
||||
'id' => $this->id,
|
||||
'product_id' => $this->priduct_id,
|
||||
'image' => image_resize($this->product->image, 100, 100),
|
||||
'product_name' => $this->product->description->name,
|
||||
'price' => currency_format($this->product->price)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ Route::prefix('/')
|
|||
Route::get('update_password', [AccountController::class, 'updatePassword'])->name('account.update_password');
|
||||
Route::get('wishlist', [WishlistController::class, 'index'])->name('account.wishlist.index');
|
||||
Route::post('wishlist', [WishlistController::class, 'add'])->name('account.wishlist.add');
|
||||
Route::delete('wishlist/{product_id}', [WishlistController::class, 'remove'])->name('account.wishlist.remove');
|
||||
Route::delete('wishlist/{id}', [WishlistController::class, 'remove'])->name('account.wishlist.remove');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue