123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use Auth;
- use App\Models\Wishlist;
- use App\Models\Category;
- class WishlistController extends Controller
- {
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function index()
- {
- $wishlists = Wishlist::where('user_id', Auth::user()->id)->paginate(9);
- return view('frontend.user.view_wishlist', compact('wishlists'));
- }
- /**
- * Show the form for creating a new resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function create()
- {
- //
- }
- /**
- * Store a newly created resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function store(Request $request)
- {
- if(Auth::check()){
- $wishlist = Wishlist::where('user_id', Auth::user()->id)->where('product_id', $request->id)->first();
- if($wishlist == null){
- $wishlist = new Wishlist;
- $wishlist->user_id = Auth::user()->id;
- $wishlist->product_id = $request->id;
- $wishlist->save();
- }
- return view('frontend.partials.wishlist');
- }
- return 0;
- }
- public function remove(Request $request)
- {
- $wishlist = Wishlist::findOrFail($request->id);
- if($wishlist!=null){
- if(Wishlist::destroy($request->id)){
- return view('frontend.partials.wishlist');
- }
- }
- }
- /**
- * Display the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function show($id)
- {
- //
- }
- /**
- * Show the form for editing the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function edit($id)
- {
- //
- }
- /**
- * Update the specified resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function update(Request $request, $id)
- {
- //
- }
- /**
- * Remove the specified resource from storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function destroy($id)
- {
- //
- }
- }
|