30 lines
638 B
PHP
30 lines
638 B
PHP
<?php
|
|
|
|
namespace Modules\Wishlist\Http\Controllers;
|
|
|
|
class WishlistController
|
|
{
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store()
|
|
{
|
|
if (! auth()->user()->wishlistHas(request('productId'))) {
|
|
auth()->user()->wishlist()->attach(request('productId'));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Destroy resources by the given id.
|
|
*
|
|
* @param string $productId
|
|
* @return void
|
|
*/
|
|
public function destroy($productId)
|
|
{
|
|
auth()->user()->wishlist()->detach($productId);
|
|
}
|
|
}
|