¨4.0.1¨
This commit is contained in:
@@ -24,6 +24,7 @@ class CreateWishListsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -2,24 +2,28 @@
|
||||
|
||||
namespace Modules\Wishlist\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class WishlistController
|
||||
{
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
if (! auth()->user()->wishlistHas(request('productId'))) {
|
||||
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)
|
||||
|
||||
@@ -2,19 +2,21 @@
|
||||
|
||||
namespace Modules\Wishlist\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class WishlistProductController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return auth()->user()
|
||||
->wishlist()
|
||||
->with('files')
|
||||
->latest()
|
||||
->paginate(20);
|
||||
->orderByPivot('created_at', 'desc')
|
||||
->paginate(10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,5 @@ use Illuminate\Support\Facades\Route;
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::post('wishlist', 'WishlistController@store')->name('wishlist.store');
|
||||
Route::delete('wishlist/{productId}', 'WishlistController@destroy')->name('wishlist.destroy');
|
||||
|
||||
Route::get('wishlist/products', 'WishlistProductController@index')->name('wishlist.products.index');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user