41 lines
858 B
PHP
41 lines
858 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Account;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Wishlist;
|
|
use Illuminate\Http\Request;
|
|
|
|
class WishlistController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$wishlists = Wishlist::with(['tour', 'flight'])
|
|
->where('user_id', auth()->id())
|
|
->latest()
|
|
->paginate();
|
|
|
|
return view('account.wishlist', compact('wishlists'));
|
|
}
|
|
|
|
public function toggle($type, $id)
|
|
{
|
|
$wishlist = Wishlist::where('user_id', auth()->id())
|
|
->where($type . '_id', $id)
|
|
->first();
|
|
|
|
if ($wishlist) {
|
|
$wishlist->delete();
|
|
} else {
|
|
Wishlist::create([
|
|
'user_id' => auth()->id(),
|
|
$type . '_id' => $id,
|
|
]);
|
|
}
|
|
|
|
return back();
|
|
}
|
|
|
|
|
|
}
|